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