1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix multiple problems with the getconf builtin (#280)

This commit fixes three problems with getconf pathbound builtin:
1. The -l/--lowercase option did not change all variable names to
   lower case.
2. The -q/--quote option now quotes all string values. Previously,
   it only quoted string values that had a space or other
   non-shellsafe character.
3. The -c/--call, -n/--name and -s/--standard options matched all
   variable names provided by 'getconf -a', even if none were
   actual matches.

Additionally, references to the confstr and sysconf functions have
been updated to reference section 3 of the man pages instead of
section 2.

src/lib/libast/port/astconf.c:
- Previously, only values that had spaces in them were quoted. Change
  that behavior to quote all string values by using the FMT_ALWAYS
  flag. Bug report: https://github.com/att/ast/issues/1173
- Not all variable names were printed in lowercase by 'getconf -l'.
  Fix it by adding a few missing instances of fmtlower.
  Bug report: https://github.com/att/ast/issues/1171
- Add the missing code to the '#if _pth_getconf_a' block to handle
  -c/-n/-s while parsing the OS's native 'getconf -a' output. This
  approach reuses code for name matching from other parts of
  astconflist(). Resolves: https://github.com/ksh93/ksh/issues/279

src/lib/libcmd/getconf.c:
- Update the documentation to note the -q flag only quotes strings.

src/cmd/ksh93/tests/bulitins.sh:
- Add regression tests for the getconf bugs fixed in this commit.

Co-authored-by: Martijn Dekker <martijn@inlv.org>
This commit is contained in:
Johnothan King 2021-04-20 19:34:54 -07:00 committed by GitHub
parent 61e0f90460
commit f28bce61a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 22 deletions

View file

@ -52,10 +52,10 @@ int astquery(int \fIfd\fP, const char* \fIformat\fP , ...);
.SH DESCRIPTION
.L astconf
is a string interface to the
.IR confstr (2),
.IR confstr (3),
.IR pathconf (2),
and
.IR sysconf (2)
.IR sysconf (3)
calls.
If
.I value
@ -269,4 +269,4 @@ and the environment variable
is used to set
.IR *cols .
.SH "SEE ALSO"
getconf(1), confstr(2), mmap(2), pathconf(2), read(2), sysconf(2), write(2)
getconf(1), confstr(3), mmap(2), pathconf(2), read(2), sysconf(3), write(2)