On 08 Jan, 2004, at 04:33, Stroller wrote: > On Jan 8, 2004, at 7:37 am, Eugene Lee wrote: >> On Wed, Jan 07, 2004 at 08:46:38PM +0000, Stroller wrote: >> : On Jan 7, 2004, at 5:41 pm, Eugene Lee wrote: >> : >: >> : >: There are annoying differences between "standard Unix" versions >> of the >> : >: utilities and their GNU counterparts. Usually they Unix versions >> are >> : >: compatible with the GNU versions, but the GNU versions are not >> : >: compatible with the Unix versions. ... Just as scripts written >> for >> : >: /bin/sh will work in /bin/ksh or /bin/bash ... scripts written >> for >> : >: either ksh or zsh will not run in sh. >> : > >> : >Too bad /bin/bash is the same as /bin/sh. :-) >> : >> : Excuse me if I missed the joke, but from `man bash`: >> : >> : DESCRIPTION >> : Bash is an sh-compatible command language interpreter >> that executes >> : commands read from the standard input or from a file. Bash >> also incor- >> : porates useful features from the Korn and C shells (ksh and >> csh). >> >> Well, bash also has useful features from ksh and csh, that means that >> these features are not available in old sh. Therefore, any bash >> script >> that uses any of these new features is not guaranteed to work on a >> machine that has the original sh and not bash. This is just another >> example of a GNU version of a tool (i.e. bash) is not compatible with >> the Unix version (i.e. sh). > > I think you missed the part I quoted in which I said: > > INVOCATION > ... > 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. > > So if one is writing a script which one wishes to be cross-platform, > one simply writes it with the header "#!/bin/sh" and any of Bash's > advanced features will be ignored; one will only be able to use sh > syntax in that script. I do not believe that is true. I believe that bash will always honor its own syntax. (But since I don't use bash, I've never tested it.) The INVOCATION paragraph you refer to simply describes which startup files are read - ~/.profile and /etc/profile only, not what syntax is observed. "Since a shell invoked as sh does not attempt to read and execute commands from any other startup files, the --rcfile option has no effect." Other than that... A) OS X does NOT have a separate /bin/sh -- it is a link to /bin/bash. (The same as csh is a link to tcsh.) B) If you write a script which begins #!/bin/sh it is an "sh" script, not a bash or ksh script. You should not be able to use any "advanced" syntax in bash with the "#!/bin/sh" invocation, but I've never tested it to see if it is true. C) if you want "#!/bin/ksh" compatibility, you have to use zsh feature -- "emulate ksh." D) Bash Bugs: "There are some subtle differences between bash and traditional versions of sh, mostly because of the POSIX specification." [Note: ksh is the POSIX shell, and historically at least, ksh scripts did not run under bash without modifications.] T.T.F.N. William H. Magill # Beige G3 - Rev A motherboard - 768 Meg # Flat-panel iMac (2.1) 800MHz - Super Drive - 768 Meg # PWS433a [Alpha 21164 Rev 7.2 (EV56)- 64 Meg]- Tru64 5.1a # XP1000 - [Alpha EV6] magill at mcgillsociety.org magill at acm.org magill at mac.com