[COLUG] Bashing your brains out with these tests
Ken Bradford
ken at alpha2.com
Mon Jun 28 09:44:15 EDT 2004
> -----Original Message-----
> From: Jim [mailto:jep200404 at columbus.rr.com]
> Sent: Friday, June 25, 2004 10:42 PM
> To: ken at alpha2.com
> Subject: Re: [COLUG] Bashing your brains out with these tests
> Importance: High
>
>
> > > For portability, you might want to avoid the BASH
> >
> > > and use only the Bourne [.
> >
> > If I can do the same thing with [ as I can with [[.
>
> I expect that you can, but I don't know how much effort it will
> take to do with just [ instead of [[. Obviously, one expects it
> to be easier with [[, otherwise, the [[ command wouldn't exist.
>
> > Is it really much of an
> > issue though when I start my scripts with "#!/bin/sh"?
>
> I think it is an issue.
>
> > Or does "#!/bin/sh" not _always_ mean bash, like I've been told?
>
> /bin/sh can be a shell other than bash.
> It's certainly common on mainline Linux distros for /bin/sh to be bash,
> but that's not a requirement.
>
> If you begin your scripts with "#!/bin/sh", I think you can presume
> bourne shell functionality, but not bash functionality.
> If you rely on bash functionality, then beginning your script with
> "#!/bin/bash" would be better.
>
> http://www.google.com/search?q=%2Fbin%2Fsh+bash
>
> Portability is a good thing.
Agreed, so _if_ I am going to use [[ ]], the I really should start the
script with "#!/bin/bash".
>
> The grammar of [[ != ]] && [[ != ]] is interesting.
> Is it one big [[ command, or is it two [[ commands,
> where the second [[ command is executed conditionally
> upon the "success" of the first command?
> How does the shell know if && is an argument to the [[ command,
> or if && is a shell thing?
Good questions. I believe your right about the second [[ command being
executed conditionally upon the "success" of the first command.
Ken Bradford
Alpha II Service, Inc.
More information about the colug
mailing list