Fixed. Ash/Dash don't support ERR traps, so I instead did this:
set +e output=$(getopt -o '' -l $options -- "$@") errout=$(getopt -o '' -l $options -- "$@" 2>&1 >/dev/null) set -e
if [[ -n "$errout" ]]; then warn_getopt $type warn "$type Error: $errout" fi
This results in much better logging during install, without stopping output to console. For example:
$ cat /var/log/syslog | grep kickseed > ... snip ... < Jun 19 01:56:26 kickseed: Failed to parse %pre options Jun 19 01:56:26 kickseed: %pre Error: getopt: unrecognized option '--log=/test.log'
I've also integrated this with test-kickseed, which outputs this:
$ ./test-kickseed custom-test.ks getopt: unrecognized option '--log=/test.log' LOG: Failed to parse some %pre options LOG: %pre Error: getopt: unrecognized option '--log=/test.log'
As you can see, getopt still prints to stderr, but now we have log messages printed as well.
Fixed. Ash/Dash don't support ERR traps, so I instead did this:
set +e
output= $(getopt -o '' -l $options -- "$@")
errout= $(getopt -o '' -l $options -- "$@" 2>&1 >/dev/null)
set -e
if [[ -n "$errout" ]]; then
warn_ getopt $type
warn "$type Error: $errout"
fi
This results in much better logging during install, without stopping output to console. For example:
$ cat /var/log/syslog | grep kickseed
> ... snip ... <
Jun 19 01:56:26 kickseed: Failed to parse %pre options
Jun 19 01:56:26 kickseed: %pre Error: getopt: unrecognized option '--log=/test.log'
I've also integrated this with test-kickseed, which outputs this:
$ ./test-kickseed custom-test.ks
getopt: unrecognized option '--log=/test.log'
LOG: Failed to parse some %pre options
LOG: %pre Error: getopt: unrecognized option '--log=/test.log'
As you can see, getopt still prints to stderr, but now we have log messages printed as well.