Bug #14044


ksh builtin getconf is missing some parameters

Added by Andy Fiddaman 25 days ago. Updated 11 days ago.

cmd - userland programs
Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


To construct its built-in getconf command, the ksh93 configuration system extracts information from the system getconf binary and from several headers.
Unfortunately, the script that does this expects GNU sed and in particular tries to use sed to substitute newlines for spaces. This does not work and as a result several parameters are not exposed in the built-in.

This was discovered when richlowe generated the ksh93 feature files on a system which had GNU sed earlier in the path than /usr/bin; there's a secondary problem that the user's path can affect the feature generation.

Note that this is not part of a standard build, it's a manual process to re-generate the feature files that ksh93 needs to build.

Actions #1

Updated by Andy Fiddaman 25 days ago

  • Description updated (diff)
Actions #2

Updated by Andy Fiddaman 20 days ago

  • Gerrit CR set to 1688
Actions #3

Updated by Andy Fiddaman 16 days ago

The root cause of this problem was discovered to be a sed expression in libast's which tries to separate a list of space-separated words across multiple lines into a file containing one word per line. The list of words is extracted from header files and this is part of the process for populating the getconf translation tables.

The original code here looked like:

sed \
    -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]/ /g' \
    -e 's/[     ][     ]*/\n/g'

and the problem is that the illumos sed command does not support escapes such as the \n there; rather it treats it as a literal n. This was resulting in the loss of several tokens from the output (unfortunately not all of them or testing would have shown up the problem!)

The new version (see the associated gerrit review):

sed \
    -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]/ /g' \
    -e 's/[     ][     ]*/%/g' | tr '%' '\n'

which replaces space sequences with % then uses tr to swap these for a newline. It's safe to use % since any existing % characters would have been replaced with a space in the previous expression.

In addition to this change, I've also updated the paths in the various .iffe make files so that it is explicit and therefore consistent between systems that may run this feature target in the future.

Actions #4

Updated by Andy Fiddaman 12 days ago

Tested by comparing the output of ksh's built-in getconf before and after this change.

Some adhoc testing shows that keys that were previously unavailable are now present:


af@bloody:~/getconf/old$ getconf UID_MAX
af@bloody:~/getconf/old$ getconf UADDR_MAX
getconf: Invalid argument (UADDR_MAX)
af@bloody:~/getconf/old$ getconf ADDRESS_WIDTH
getconf: Invalid argument (ADDRESS_WIDTH)
af@bloody:~/getconf$ getconf ISALIST
getconf: Invalid argument (ISALIST)


af@bloody:~/getconf/new$ getconf UID_MAX
af@bloody:~/getconf/new$ getconf UADDR_MAX
af@bloody:~/getconf/new$ getconf ADDRESS_WIDTH
af@bloody:~/getconf/new$ getconf ISALIST
amd64 pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86

and other comparisons show more attributes being provided than before:

--- old/all     2021-09-02 00:03:54.152609154 +0000
+++ new/all     2021-09-02 00:47:03.500851286 +0000
@@ -1,6 +1,9 @@
@@ -10,6 +13,10 @@
Actions #5

Updated by Electric Monk 11 days ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Closed

git commit 78f5fe539528ce4afb4d8137ae7f8ff44765b467

commit  78f5fe539528ce4afb4d8137ae7f8ff44765b467
Author: Andy Fiddaman <>
Date:   2021-09-15T08:14:24.000Z

    14044 ksh builtin getconf is missing some parameters
    Reviewed by: Toomas Soome <>
    Reviewed by: Rich Lowe <>
    Approved by: Gordon Ross <>


Also available in: Atom PDF