Thread: Unportable use of uname in pg_upgrade test script
BTW, I tried the pg_upgrade regression tests this morning on my dinosaur HPUX box, and it promptly fell over with: uname: illegal option -- o usage: uname [-amnrsvil] [-S nodename] make: *** [check] Error 1 This is not terribly surprising, because the -o option is nowhere to be seen in the Single Unix Spec definition of uname; which means this is likely to fail on other platforms too. I would suggest using -s, or no option at all, or finding some other way to identify Windows/MSys. regards, tom lane
On 09/29/2012 12:13 PM, Tom Lane wrote: > BTW, I tried the pg_upgrade regression tests this morning on my dinosaur > HPUX box, and it promptly fell over with: > > uname: illegal option -- o > usage: uname [-amnrsvil] [-S nodename] > make: *** [check] Error 1 > > This is not terribly surprising, because the -o option is nowhere to be > seen in the Single Unix Spec definition of uname; which means this is > likely to fail on other platforms too. I would suggest using -s, or no > option at all, or finding some other way to identify Windows/MSys. The trouble with uname -s is that its output is a bit variable. I think this will work: testhost=`uname -a | sed 's/.* //'` cheers andrew
Andrew Dunstan <andrew@dunslane.net> writes: > The trouble with uname -s is that its output is a bit variable. I think > this will work: > testhost=`uname -a | sed 's/.* //'` What do you mean by "a bit variable"? And why would that fix it? The output of -a is *defined* to be the same as -s followed by other stuff. The reference page I'm looking at also points out that the -s string can contain embedded blanks. regards, tom lane
On 09/29/2012 01:06 PM, Tom Lane wrote: > Andrew Dunstan <andrew@dunslane.net> writes: >> The trouble with uname -s is that its output is a bit variable. I think >> this will work: >> testhost=`uname -a | sed 's/.* //'` > What do you mean by "a bit variable"? On one of my machines uname -s return MINGW32_NT5.1 On another it says MINGW32_NT6.1 > And why would that fix it? The > output of -a is *defined* to be the same as -s followed by other stuff. > The reference page I'm looking at also points out that the -s string > can contain embedded blanks. Exactly, the sed script pulls the last token from the line, which is Msys on all my Mingw systems. If you want to do it another way we could possibly pass the PORTNAME from the global make file. cheers andrew
Andrew Dunstan <andrew@dunslane.net> writes: > Exactly, the sed script pulls the last token from the line, which is > Msys on all my Mingw systems. Perhaps that's "uname -v"? > If you want to do it another way we could possibly pass the PORTNAME > from the global make file. That might be safer. The last few words of uname's output are *completely* unstandardized (the spec says that implementation-defined fields can be added to -a's output ...) regards, tom lane > cheers > andrew
On Sat, 2012-09-29 at 13:33 -0400, Andrew Dunstan wrote: > On 09/29/2012 01:06 PM, Tom Lane wrote: > > Andrew Dunstan <andrew@dunslane.net> writes: > >> The trouble with uname -s is that its output is a bit variable. I think > >> this will work: > >> testhost=`uname -a | sed 's/.* //'` > > What do you mean by "a bit variable"? > > On one of my machines uname -s return MINGW32_NT5.1 > > On another it says MINGW32_NT6.1 You could do case $testhost in MINGW*) something;; Or call config.guess, which exists more or less for this purpose.