home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.22 / text0087.txt < prev    next >
Encoding:
Text File  |  1991-03-06  |  2.2 KB  |  51 lines

  1. Submitted-by: karish@mindcraft.com (Chuck Karish)
  2.  
  3. In article <17400@cs.utexas.edu> gwyn@smoke.brl.mil (Doug Gwyn) wrote:
  4. >In article <17155@cs.utexas.edu> jack@cwi.nl (Jack Jansen) writes:
  5. >>I don't see any problem in the shell reading the first line and
  6. >>checking it for #!/bin/sh.
  7. >
  8. >Shells that have done this (e.g. some csh implementations on UNIX System V)
  9. >have definitely caused problems.  For example, Most of my shell scripts
  10. >start with #!/usr/5bin/sh to ensure System V semantics on BSD systems;
  11. >however, on a genuine UNIX System V system I was expecting the script to
  12. >be interpreted by /bin/sh (even if executed by csh).
  13.  
  14. It would seem that programmer expectations were more at fault here than
  15. were the SysV shells.  The scripts he described were designed to
  16. exploit a difference in the behavior of shells on different systems.  I
  17. don't understand why it worked, though.  On some older SysV-based
  18. systems I've used, scripts that start with the '#' character are
  19. interpreted as csh scripts no matter what follows the '#'.
  20.  
  21. Some systems that honor "#! /bin/whatever" do not default to csh if the
  22. file starts with just "#".
  23.  
  24. The need for a hard-coded path makes scripts that depend on the "#!"
  25. mechanism non-portable. "/usr/5bin/sh" is the right path for a shell
  26. with full SysV functionality on a Sun.  On a DEC system, the
  27. incantation is "/bin/sh5"; on other systems, the correct name might be
  28. "/usr/usg/sh" or "/bin/bsh".  Perhaps what we need is a standard set of
  29. non-filename identifiers for shells.
  30.  
  31. Creative use of links can help alleviate this problem on existing
  32. systems.
  33.  
  34. I would be more optimistic that the adoption of the 1003.2 standard
  35. would solve this problem if I hadn't already seen the many different
  36. ways that vendors have isolated 1003.1 behavior in compatibility
  37. modes.  Operating system standards won't live up to their full
  38. potential until they're accepted as the default interfaces.
  39.  
  40. To change the subject a little, what features of modern sh
  41. implementations cause scripts written for the BSD sh to fail?  I
  42. presume there's a reason that BSD vendors don't install a SysV sh in
  43. /bin.  Followups on this point should probably go to comp.unix.shell.
  44. -- 
  45.  
  46.     Chuck Karish        karish@mindcraft.com
  47.     Mindcraft, Inc.        (415) 323-9000
  48.  
  49. Volume-Number: Volume 22, Number 90
  50.  
  51.