-
Type:
Story
-
Status: Done
-
Priority:
Medium
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.11.0
-
Component/s: Masterfiles Policy Framework (MPF/COPBL/STDLIB)
-
Labels:None
-
Environment:Solaris/SunOS
https://unix.stackexchange.com/a/260770/135943 has some crucial background information. To excerpt a portion of this:
Like for many other utilities, Solaris (contrary to most other Unices) has taken the stance of sticking with the older obsolete implementation for its default awk utility, and make the newer versions available either under a different name (nawk) or at a different location (/usr/xpg4/bin/awk).
On Solaris, if you use the default environment, you generally get utilities that behave in an ancient/obsolete way. For instance, before Solaris 11, sh in the default environment would not be a standard shell, but a Bourne shell. A lot of other utilities (grep, sed, tail, df...) are not POSIX compliant, not even to the 1992 version of the standard.
Solaris is a POSIX (even Unix) certified system, however POSIX/Unix only requires a system be compliant in a given (documented) environment (which may not be the default).
So, when you write code that needs to be portable to Solaris, you need either to write in a syntax from another age, or make sure you put yourself in a POSIX environment.
The purpose of the "paths.cf" file is surely to allow portable calls to utilities. If the utilities will behave in unpredictably different ways on different systems, the policy portability gained by using e.g. $(paths.path[awk]) is lost.
Here is a common Awk idiom for printing only the first instance of each distinct line from its input. (It's similar to uniq, except does not require its input to be sorted as uniq does.)
$ uname -a SunOS apggd27 5.10 Generic_118833-36 sun4v sparc SUNW,Sun-Fire-T200 $ type -a awk awk is /usr/bin/awk $ PATH="$(getconf PATH)" type -a awk awk is /usr/xpg4/bin/awk awk is /usr/bin/awk $ printf '%s\n' apple banana pear apple cherry banana | /usr/bin/awk '!x[$0]++' awk: syntax error near line 1 awk: bailing out near line 1 $ printf '%s\n' apple banana pear apple cherry banana | /usr/xpg4/bin/awk '!x[$0]++' apple banana pear cherry $
As you can see, this common Awk idiom (using only POSIX-specified features) fails to work using the default awk available on SunOS, but does work when run with the POSIX awk. (The POSIX awk is located by using the output of getconf PATH to set the path, as described here and here.)
The "paths" library in CFEngine does not point to these POSIX-compliant versions of the tools, but points to the ancient versions provided in the default Solaris environment.
Actually, the getconf tool could be used to improve portability of CFEngine commands promises in future CFEngine versions, but that would be a more drastic change. What I'm asking for in this ticket is for the "paths.cf" lib to be updated so that Solaris commands can be used with the expectancy that they will support standard features if possible.
- relates to
-
CFE-1804 path list for commands
-
- Open
-