home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.24 / text0058.txt < prev    next >
Encoding:
Text File  |  1991-09-03  |  1005 b   |  26 lines

  1. Submitted-by: eric@mks.uucp (Eric Gisin)
  2.  
  3. In article <1991Jul21.222926.12659@uunet.uu.net> brnstnd@KRAMDEN.ACF.NYU.EDU (Dan Bernstein) writes:
  4.    In article <1991Jul19.033239.8917@uunet.uu.net> Chuck Karish (karish@mindcraft.com) writes:
  5. >   > A puzzle for the reader (maybe this is obvious to everyone but
  6.    > me):  How can a shell script determine whether it's running on
  7.    > a POSIX.2 system?  If it calls getconf and getconf does not
  8.    > exist, the shell may exit.  It could call getconf in a
  9.    > subshell, but that's ugly and expensive.
  10.  
  11. >   Congratulations. You just hit the nail right on the head.
  12.  
  13. I don't see any problem. The most obvious solution is:
  14.     if PATH=`command -p getconf _CS_PATH`;
  15.     then # POSIX.2
  16.     else PATH=<default>
  17.     fi
  18. Or simply:
  19.     PATH=`command -p getconf _CS_PATH` || PATH=<default>
  20.  
  21. There is a problem if you want to redirect command's error with 2>/dev/null.
  22. Existing shells may print errors after (Korn) or before (Bourne) redirection.
  23.  
  24. Volume-Number: Volume 24, Number 59
  25.  
  26.