diff options
author | Manoj Srivastava <srivasta@debian.org> | 2009-03-20 21:57:01 -0500 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2009-03-20 21:57:01 -0500 |
commit | 6e5ba1bb05ff509f8fdd1a60fe888c97003adba8 (patch) | |
tree | 748d2821e142884fd6a2a338ad739edcd0a25fb1 /ucf | |
parent | 6af25df60eb2b8be5b1a5986bcb34eefaf644bea (diff) |
Save and restore command line arguments after parsing
This way, when the script is called again under debconf, the command line
arguments are still around, and have not been eliminated during
parsing. And no, getopt was notto blame, ucf was nuking the commandline
itself.
closes: Bug#520073
Signed-Off-By: Manoj Srivastava <srivasta@debian.org>
Diffstat (limited to 'ucf')
-rwxr-xr-x | ucf | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -253,6 +253,10 @@ replace_conf_file () { replace_md5sum; } +# Escape single quotes in the arguments passed in +quote_single() { + echo "$1" | sed -e "s,','\\\\'',g" +} @@ -276,6 +280,12 @@ DIST_SUFFIX="ucf-dist" NEW_SUFFIX="ucf-new" OLD_SUFFIX="ucf-old" +# save up the cmdline with proper quoting/escaping +for arg in "$@"; do + saved="${saved:+$saved }'$(quote_single "$arg")'" +done + + # Note that we use `"$@"' to let each command-line parameter expand to a # separate word. The quotes around `$@' are essential! # We need TEMP as the `eval set --' would nuke the return value of getopt. @@ -319,6 +329,10 @@ while true ; do *) echo >&2 "Internal error!" ; exit 1 ;; esac done + +# now we can restore $@ +eval set -- "$saved" + ###################################################################### ######## ######### ######## Sanity checking ######### |