On Fri, Mar 26, 2004 at 05:04:34PM +0000, Stroller wrote: : : On Mar 26, 2004, at 12:15 pm, Eugene Lee wrote: : > : >: #! /bin/sh : > : >No spaces here, it should be "#!/bin/sh" (without the quotes). : : It's probably more elegant to use #!/bin/bash at the beginning of your : scripts, as we don't actually have a Bourne shell on our Macs. True, but not everyone has /bin/bash. Some have /usr/local/bin/bash. /bin/sh is guaranteed to be more portable. : In : additional to its superset of commands `bash` does, I believe, behave : slightly differently from traditional `sh`; if invoked as `sh` Bash : _should_ behave as `sh`, however I am not aware that this has been : demonstrated. [1] Actually, the binary does behave differently according to the man page: ... --norc Do not read and execute the personal initialization file ~/.bashrc if the shell is interactive. This option is on by default if the shell is invoked as sh. ... If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well. When invoked as an interac- tive login shell, or a non-interactive shell with the --login option, it first attempts to read and execute commands from /etc/profile and ~/.profile, in that order. The --noprofile option may be used to inhibit this behavior. When invoked as an interactive shell with the name sh, bash looks for the variable ENV, expands its value if it is defined, and uses the expanded value as the name of a file to read and execute. Since a shell invoked as sh does not attempt to read and exe- cute commands from any other startup files, the --rcfile option has no effect. A non-interactive shell invoked with the name sh does not attempt to read any other startup files. When invoked as sh, bash enters posix mode after the startup files are read. ... Bash attempts to determine when it is being run by the remote shell daemon, usually rshd. If bash determines it is being run by rshd, it reads and executes commands from ~/.bashrc, if that file exists and is readable. It will not do this if invoked as sh. The --norc option may be used to inhibit this behavior, and the --rcfile option may be used to force another file to be read, but rshd does not generally invoke the shell with those options or allow them to be specified. However, the differences are slight at best and are not worth arguments that are better reserved for more interesting topics. -- Eugene Lee http://www.coxar.pwp.blueyonder.co.uk/