On Wed, Aug 27, 2003 at 10:17:44PM +1000, Ken Foskey wrote:
> On Wed, 2003-08-27 at 20:03, Andrew McNaughton wrote:
> > * Most non-linux systems don't have a file at /bin/bash.  /bin/sh will
> > always be there.
> 
> Then you can code this in your if statements
> 
> if [ -f $FILENAME ] ; then
> fi
> 
> And it will not work.   This is not valid /bin/sh scripts, because most

It will if /usr/bin/[ exists:

    [EMAIL PROTECTED] ~]$ ls -l /usr/bin/[
    lrwxrwxrwx    1 root     root            4 Oct  4  2002 /usr/bin/[ -> test
    [EMAIL PROTECTED] ~]$ rpm -qf /usr/bin/[
    sh-utils-2.0.11-14

Or you can use this instead:

    if test -f $FILENAME; then
        ...
    fi

which will work on all shells.

> Don't do this unless it is necessary.

I disagree.  Use /bin/sh unless you really need something that bash
provides and sh doesn't.


Cheers,

John
-- 
whois [EMAIL PROTECTED]
GPG key id: 0xD59C360F
http://kirriwa.net/john/
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to