Bug 109826 - test does not function properly within /bin/sh script
test does not function properly within /bin/sh script
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: bash (Show other bugs)
1
athlon Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-11-12 00:19 EST by Ryan Daly
Modified: 2007-11-30 17:10 EST (History)
1 user (show)

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


Attachments (Terms of Use)

  None (edit)
Description Ryan Daly 2003-11-12 00:19:37 EST
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 04:08:06 EST
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 04:56:20 EST
Reported upstream via bashbug.

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