[COLUG] Portability of shell scripts

Jim jep200404 at columbus.rr.com
Mon Jun 28 12:26:39 EDT 2004


Ken Bradford <ken at alpha2.com> wrote:

You replied: 

> > Portability is a good thing.
> 
> Agreed, so _if_ I am going to use [[ ]], the I really should start the
> script with "#!/bin/bash".

There are two separate issues.  

If your script is using non-bourne features of bash then it 
should specify /bin/bash rather than just /bin/sh.  
This is only tangentially related to portability.  
If the system doesn't have bash, 
your script won't work regardless of how you specify the shell.  

To make your script more portable, 
it should not rely on non-bourne features of bash.  
You should use only plain bourne shell capabilities.  
This is substantive portability and is good.  

> > 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. 

And that's all that they were.  

> I believe your right about the second [[ command being
> executed conditionally upon the "success" of the first command.

You read more into what I wrote than I either wrote or meant.  
My questions were not rhetorical.  
I did not give or even hint at the answers.  
I do not know that the second [[ is a command 
executed conditionally upon the sucess of the first [[ command.  

Jim



More information about the colug mailing list