Prev: bash script: variable(s) in an internal cmd line
Next: Directory creation and file moving by modification dates?
From: bsh on 1 Aug 2010 17:35
David Kirkby <drkir...(a)gmail.com> wrote:
> I have this in a script, where $UNAME will be the output of 'uname',
> except on Cygwin, where it will be "CYGWIN".
P.S. I hope you are not writing your own host detection script.
The best one is config.guess from the autoconf distribution:
config.guess.sh; config.sub.sh: "determine 'canonical host triple'"
.... But plenty others exist, including:
archguess.sh: "determine OS/distribution/version: NCA?"
archit.sh: "guess machine's application architecture"
platform.sh: "platform identification utility"
whatami.sh: "determine type of host: contained-in Msys distribution"
> What of the following two lines is more portable?
> if [ "x$UNAME" != xSunOS ] && [ "x$UNAME" != xCYGWIN ] && [ "x$UNAME" !
> = xHP-UX ]; then
> if [ "$UNAME" = SunOS -a "$UNAME" = CYGWIN -a "$UNAME" = HP-UX ]; then
> I believe the former is more portable, but someone has suggested the
> use of the latter.
I'm a bit confused as this is a question already asked and answered: