On Tue, May 08, 2007 at 09:30:00AM -0400, Celejar wrote: > On Tue, 8 May 2007 11:04:02 +0300 > [EMAIL PROTECTED] (Andrei Popescu) wrote: > > > On Mon, May 07, 2007 at 08:27:45PM -0400, Celejar wrote: > > > > > Minor nit: in Debian, '/bin/sh' is a symlink to bash; I don't know what > > > it is on other systems. So IIUC, when you write '#!/bin/sh', you aren't > > > really specifying a shell, but are rather saying 'use the standard > > > shell'. > > > > Which can be different from system to system: > > That's what I meant to imply. > > > ls -l /bin/sh > > lrwxrwxrwx 1 root root 9 2007-03-23 02:30 /bin/sh -> /bin/dash > > > > /bin/sh is rather used for POSIX compatibility. > > That's sort of what I meant; I was responding to Andrew who had implied > that writing '/bin/sh' will '[ensure] script compatibility across > different systems'
okay, so that one maybe didn't belong in the list since its generally just a link (though I note that 'man dash' provides the 'sh' manpage...). Anyway, what I meant was by specifying the shell with #!/bin/bash, you were ensuring that you got the shell you wanted regardless of what system you were on. Leaving it out means that the shell interpreter will use the default shell to execute the script. If you're on a system using ksh as the default, but your script is written for bash and happens to use bits of bash that are not compatible with ksh, then your script will fail, or even worse, not work properly. With that there, then the shell will launch an instance of bash to execute the script in. What is the other method? isn't it '#!/bin/exec bash' or something like that? I can't remember. A
signature.asc
Description: Digital signature