head 1.6; access; symbols pkgsrc-2013Q2:1.6.0.30 pkgsrc-2013Q2-base:1.6 pkgsrc-2012Q4:1.6.0.28 pkgsrc-2012Q4-base:1.6 pkgsrc-2011Q4:1.6.0.26 pkgsrc-2011Q4-base:1.6 pkgsrc-2011Q2:1.6.0.24 pkgsrc-2011Q2-base:1.6 pkgsrc-2009Q4:1.6.0.22 pkgsrc-2009Q4-base:1.6 pkgsrc-2008Q4:1.6.0.20 pkgsrc-2008Q4-base:1.6 pkgsrc-2008Q3:1.6.0.18 pkgsrc-2008Q3-base:1.6 cube-native-xorg:1.6.0.16 cube-native-xorg-base:1.6 pkgsrc-2008Q2:1.6.0.14 pkgsrc-2008Q2-base:1.6 pkgsrc-2008Q1:1.6.0.12 pkgsrc-2008Q1-base:1.6 pkgsrc-2007Q4:1.6.0.10 pkgsrc-2007Q4-base:1.6 pkgsrc-2007Q3:1.6.0.8 pkgsrc-2007Q3-base:1.6 pkgsrc-2007Q2:1.6.0.6 pkgsrc-2007Q2-base:1.6 pkgsrc-2007Q1:1.6.0.4 pkgsrc-2007Q1-base:1.6 pkgsrc-2006Q4:1.6.0.2 pkgsrc-2006Q4-base:1.6 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.6 date 2006.11.05.09.09.20; author rillig; state dead; branches; next 1.5; 1.5 date 2006.11.05.07.24.04; author rillig; state Exp; branches; next 1.4; 1.4 date 2006.10.20.10.14.44; author rillig; state Exp; branches; next 1.3; 1.3 date 2006.10.07.08.13.21; author rillig; state Exp; branches; next 1.2; 1.2 date 2006.10.06.22.18.33; author rillig; state Exp; branches; next 1.1; 1.1 date 2006.10.06.21.10.41; author rillig; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2006.10.06.21.10.41; author rillig; state Exp; branches; next ; desc @@ 1.6 log @Removed the pkgsrc portability book, as editing DocBook XML is no fun at all. The contents has been moved to the NetBSD wiki at: http://wiki.aydogan.net/index.php/The_pkgsrc_portability_guide @ text @ Command line utilities This chapter collects the various bugs and peculiarities of the POSIX-like utilities on the platforms. ls On MacOS X, ls does not return an error code when the file to be listed does not exist. On some other platforms, it does. sh Non-standard extensions The variable RANDOM is an addition of ksh, and bash can do it as well. The command [[ is an addition of ksh, and bash can do it as well. NetBSD On NetBSD, have a look at the various PRs to see what's wrong with the shell. Solaris On Solaris, /bin/sh is missing some features that POSIX requires for the sh utility: $ if ! false; then echo ok; fi !: not found $ echo ${PWD%/} bad substitution $ foo=$(true) syntax error: `foo=$' unexpected There is another sh implementation in /usr/xpg4/bin, which implements these features. However, many shell scripts and other programs have /bin/sh hard-coded. Another incompatibility is this: $ set -- foo bar baz; echo "before: $#"; set --; echo "after: $#" before: 3 after: 3 All(?) other shells, including /usr/xpg4/bin/sh, reply with after: 0. On Solaris, both /bin/sh and /usr/xpg4/bin/sh cannot handle empty for loops. $ for i in ; do echo "i=$i"; done syntax error: `;' unexpected The work-around is either to add some dummy arguments or to save the list of things in a variable. Looping over empty lists is no problem. But note that the various parameter expansions that are applied here differ in this case. $ things=""; for i in $things; do echo "i=$i"; done Globbing problems with quoting and hidden files rm -rf "testdir" mkdir "testdir" touch "testdir/.file" x="." y=".file" echo "=== x and y quoted" ls "$x"/*/"$y" echo "=== only x quoted" ls "$x"/*/$y echo "=== nothing quoted" ls $x/*/$y The result of running this code with /bin/sh is that in the first case, the result of the globbing expansion is ./*/.file, while in the two other cases, it is the correct ./testdir/.file. This does only happen when y starts with a dot, that is, for hidden files. test Supported options It is expected that the test utility fully supports the POSIX standard. Any deviations from it are recorded in the Unsupported column. Supported options of the <emphasis>test</emphasis> utility PlatformUnsupportedSupportedExtensionsAIX-4.3-powerpcbcdefghLnprstuwxzkIRIX-6.5-mipsebbcdefghLnprstuwxzkLinux-2.6.*-*bcdefgLnprSstuwxzGkO nt ot efNetBSD-3.0-*bcdefgLnprSstuwxzGkO nt ot efSunOS-5.10-* /bin/sheSbcdfghLnprstuwzkSunOS-5.10-* /bin/testbcdefgLnprSstuwxzaGkOo nt ot ef
Remarks: On Solaris-5.10-*, the behavior of the -f operator depends on the value of the environment variable PATH. On Solaris-5.10-*, /usr/ucb/test behaves like the builtin command in /bin/sh. On the other hand, /usr/bin/test conforms to POSIX.
Non-standard extensions The Bourne Again Shell (bash) allows the binary operator == to be used as an alias for =. This leads to problems when programs using this feature are ported to other platforms. By the way, not even the GNU coreutils have that feature, it's really only Bash that does. After all, there is no apparent benefit for having two names for the same operator. Bugs On NetBSD upto X.Y (see PR 34646), the &man.test.1; utility cannot handle the following: test ! = foo POSIX requires that when test is called with three arguments, the second operand is checked first to see whether it is a binary operator. On NetBSD, the unary ! operator takes precedence.
@ 1.5 log @On the platforms to which I have access, I checked the features of the "test" utility. Except for the "-e" operator on Solaris, it seems that we can use everything that is specified in POSIX. @ text @d1 1 a1 1 @ 1.4 log @ls(1) on MacOS X returns 0 on error. @ text @d1 1 a1 1 d128 41 @ 1.3 log @Collected some non-standard extensions for sh(1). @ text @d1 1 a1 1 d10 9 d131 1 a131 1 The Bourne Again Shell (Bash) allows the binary operator @ 1.2 log @Provided a link to the Open Group's utilities web page. Tested "test foo == bar" with test(1) from the GNU coreutils. It does _not_ know the "==" operator. @ text @d1 1 a1 1 d13 13 @ 1.1 log @Initial revision @ text @d1 1 a1 1 d7 2 a8 1 POSIX-like utilities on the platforms. d112 4 a115 2 other platforms. Furthermore, there is no apparent benefit for having two names for the same operator. @ 1.1.1.1 log @Imported portability-book. The pkgsrc portability book covers many of the platform-specific issues that are useful when writing programs that are portable to a great number of UNIX-like operating systems. @ text @@