Activity log for bug #1331814

Date Who What changed Old value New value Message
2014-06-18 21:13:15 Hamilton Turner bug added bug
2014-06-18 21:14:00 Hamilton Turner description Multiple handlers use the following syntax: eval set -- "$(getopt -o '' -l interpreter: -- "$@")" || { warn_getopt %pre; return; } As mentioned in "/usr/share/doc/util-linux-ng-2.17.2/getopt-parse.bash", this will never call the warning: # We need TEMP as the `eval set --' would nuke the return value of getopt. TEMP=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \ -n 'example.bash' -- "$@"` Here is a simple example to prove this: #!/bin/sh trap 'echo ERROR happened' ERR echo begin eval set -- "$(false)" echo end Because of this, almost every bug report mentions something along the lines of "getopt printed an error". This is getout outputting to stderr, but the exit code is being swallowed and errexit is not happening. This coding was probably designed intentionally to disable automatic exit whenever getopt found an unexpected argument, due to the fact that this (currently) happens on almost every kickstart file as our syntax support is quite limited. However, it also hides the warning from the user, which I believe is the real bug. Moreover, the only error is printed briefly to a terminal and then never seen again, which makes it tough for people to put in bug reports. Perhaps a better solution would be to use set +x and set -e to temporarily disable errexit, and use a trap on ERR to ensure that these errors are caught and printed to both syslog and the current TTY. Multiple handlers use the following syntax:      eval set -- "$(getopt -o '' -l interpreter: -- "$@")" || { warn_getopt %pre; return; } As mentioned in "/usr/share/doc/util-linux-ng-2.17.2/getopt-parse.bash", this will never call the warning:     # We need TEMP as the `eval set --' would nuke the return value of getopt.    TEMP=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \       -n 'example.bash' -- "$@"` Here is a simple example to prove this:     #!/bin/sh     trap 'echo ERROR happened' ERR     echo begin     eval set -- "$(false)"     echo end Because of this, almost every bug report mentions something along the lines of "getopt printed an error". This is getout outputting to stderr, but the non-zero exit code is being swallowed and errexit is not happening. This coding was probably designed intentionally to disable automatic exit whenever getopt found an unexpected argument, due to the fact that this (currently) happens on almost every kickstart file as our syntax support is quite limited. However, it also hides the warning from the user, which I believe is the real bug. Moreover, the only error is printed briefly to a terminal and then never seen again, which makes it tough for people to put in bug reports. Perhaps a better solution would be to use set +x and set -e to temporarily disable errexit, and use a trap on ERR to ensure that these errors are caught and printed to both syslog and the current TTY.
2014-06-19 06:24:52 Launchpad Janitor branch linked lp:~hamiltont-x/kickseed/kickseed
2014-06-19 06:34:43 Hamilton Turner kickseed (Ubuntu): status New Fix Committed
2014-06-19 06:34:43 Hamilton Turner kickseed (Ubuntu): assignee Hamilton Turner (hamiltont-x)