summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrestez Dan Leonard <cdleonard@gmail.com>2010-02-07 01:05:51 +0200
committerCrestez Dan Leonard <cdleonard@gmail.com>2010-02-09 15:18:19 +0200
commit1c4b461882c94febb39a550e0fe3065208139757 (patch)
tree2d4a8bc6b961e2368ab86567ba0bae3b4ca36366
parentb493869b8d4e5b2a1715d15c86dd3a3a01739299 (diff)
downloadbash-completion-1c4b461882c94febb39a550e0fe3065208139757.tar.gz
(mount) Fix leaking fs_* vars to the environment. Explicitly save/restore IFS to be posix conformant.
-rw-r--r--contrib/mount10
1 files changed, 8 insertions, 2 deletions
diff --git a/contrib/mount b/contrib/mount
index 41afb07d..bfa2a273 100644
--- a/contrib/mount
+++ b/contrib/mount
@@ -29,7 +29,9 @@ _reply_compgen_array()
ecur="${ecur/#$\'/\$\'}"
# Actually generate completions.
+ local oldifs="$IFS"
IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)'
+ IFS="$oldifs"
# Strip starting $' in reply if present in cur.
# This is necesarry because readline interprets everything after ' as a
@@ -48,10 +50,14 @@ _linux_fstab()
COMPREPLY=()
# Read and unescape values into COMPREPLY
+ local fs_spec fs_file fs_other
while read -r fs_spec fs_file fs_other; do
if [[ $fs_spec = [#]* ]]; then continue; fi
- [[ $fs_spec = */* ]] && { IFS=$'\0' eval "COMPREPLY+=( $'$fs_spec' )"; }
- [[ $fs_file = */* ]] && { IFS=$'\0' eval "COMPREPLY+=( $'$fs_file' )"; }
+ local oldifs="$IFS"
+ IFS=$'\0'
+ [[ $fs_spec = */* ]] && eval "COMPREPLY+=( $'$fs_spec' )";
+ [[ $fs_file = */* ]] && eval "COMPREPLY+=( $'$fs_file' )";
+ IFS="$oldifs"
done
_reply_compgen_array