Bug 109826 - test does not function properly within /bin/sh script
Summary: test does not function properly within /bin/sh script
Alias: None
Product: Fedora
Classification: Fedora
Component: bash   
(Show other bugs)
Version: 1
Hardware: athlon
OS: Linux
Target Milestone: ---
Assignee: Tim Waugh
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-11-12 05:19 UTC by Ryan Daly
Modified: 2007-11-30 22:10 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-11-12 09:56:20 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description Ryan Daly 2003-11-12 05:19:37 UTC
Description of problem:
I have a script that performs a test ([ -w /etc/passwd ]), and it's
returning as if /etc/passwd is writable when it really isn't.  I had
set the immutable flag on /etc/passwd, then ran the script, and it
didn't pick up that passwd was not writable.  This works on RH9.

Version-Release number of selected component (if applicable):
RH9 - test (GNU coreutils) 4.5.3
Fedora 1 - test (GNU coreutils) 5.0

Actual results:
Script functions as if /etc/passwd was writable, when in fact it's not.

Expected results:
Test should return the proper value to allow scripts to function properly.

Additional Info:
Test does appear to return the proper values.  For instance, if I do a
'test -w /etc/passwd' at a prompt, then 'echo $status', it doesn't
return a 0 to me.  However, in scripts, this doesn't appear to be caught.

Comment 1 Tim Waugh 2003-11-12 09:08:06 UTC
You filed this bug against coreutils, but the coreutils-provided
'test' (/usr/bin/test) uses access(2) to determine writability -- and
this returns the result you want.

The bash built-in (both [ and test) use stat(2) and this just looks at
the regular file permissions.

Comment 2 Tim Waugh 2003-11-12 09:56:20 UTC
Reported upstream via bashbug.

Note You need to log in before you can comment on or make changes to this bug.