OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: clofland on October 14, 2005, 10:52:31 am

Title: Test -f Behaves Oddly After Cd Command
Post by: clofland on October 14, 2005, 10:52:31 am
Write this script:

cd /bin
if (test -f joe);then echo yes1;fi
if (test -f joe);then echo yes2;fi

and run it. (You can use any dir, it doesn't have to be /bin)

There is NO file called "joe" in my /bin directory, but I always get "yes1" but not "yes2"

Is this some known bash or Linux issue where you always get a false possitive on a test -f after you do a cd command?

This causes some of the built in scripts like /etc/ppp/ppp-off to throw out errors sometimes.
Title: Test -f Behaves Oddly After Cd Command
Post by: pgas on October 14, 2005, 01:30:13 pm
hmm, interesting.

If I place your script on a partition of the internal flash (/ or /home) , it doesn't work correctly.

If I place the same script on my ext3 formatted or on a nfs mount, it works correctly.

if you drop the parentheses it works correctly everywhere.

I tried with "test" from coreutils instead of the "test" from busybox, with the same results.

somehow jffs2 seems to cause problems, i don't have an explanation
Title: Test -f Behaves Oddly After Cd Command
Post by: inode0 on October 14, 2005, 02:21:40 pm
Quote
Write this script:

cd /bin
if (test -f joe);then echo yes1;fi
if (test -f joe);then echo yes2;fi

and run it. (You can use any dir, it doesn't have to be /bin)

There is NO file called "joe" in my /bin directory, but I always get "yes1" but not "yes2"

Is this some known bash or Linux issue where you always get a false possitive on a test -f after you do a cd command?
Just tested on my 6k and I don't see this bizarre behavior. Nothing is printed from either if statement as one would expect.

John