part of shnell – a source to source compiler enhancement tool
© Jens Gustedt, 2018
Evaluate the argument list as the names of POSIX’ getconf configuration
variables and substitue with the value
Usage:
Replace meta-variable NAMEx
(${NAME0}
, ${NAME1}
…) by the values of POSIX’ getconf configuration variables VARIABLEx
. A leading underscore in such a POSIX configuration variable can be omitted. E.g the POSIX variable _REGEX_VERSION
can be refered to as REGEX_VERSION
.
If NAMEx=
is omitted NAMEx
defaults to VARIABLEx
.
Two POSIX variables are always caught from the environment, POSIX_VERSION
and POSIX2_VERSION
. Thus a portable method to ensure that a platform is POSIX is to add
On a POSIX platform this should expand to something as
On other platforms this should be
POSIX variables could be obtained with the C APIs sysconf
and confstr
. The first type of variable results in an integer value that is of type long
. We add the L
integer suffix where we detect an integer value. For variables that are not provided by the platform, the return value is -1
.
The second type of variable results in a string. These should not be used with the ${NAMEx}
notation but only with #${NAMEx}
.
Example:
#pragma CMOD amend getconf FALLBACK_PATH=PATH INT_MAX
char fallback[] = #${FALLBACK_PATH};
long int_max[] = ${INT_MAX};
This should be replaced by something similar to
Coding and configuration
The following code is needed to enable the sh-module framework.SRC="$_" . "${0%%/${0##*/}}/import.sh"
Imports
The following sh
-modules are imported: