diff options
author | Freddy Vulto <fvulto@gmail.com> | 2009-09-25 09:36:29 +0200 |
---|---|---|
committer | Freddy Vulto <fvulto@gmail.com> | 2009-09-25 09:36:29 +0200 |
commit | cfcf9fae8fbd79350829b2917f9fa40a32beb7d9 (patch) | |
tree | 16f28ae19e647ffdc303e088d71754ddd845b9c0 /contrib/shadow | |
parent | f871fe4101ed89cb98e201aed8c975fd3061905b (diff) | |
download | bash-completion-cfcf9fae8fbd79350829b2917f9fa40a32beb7d9.tar.gz |
Quote unquoted $cur to prevent globbing.
Closes Alioth #311614
Globbing might occur if $cur contains one of these globbing characters: * ? [ ]
The bug becomes apparent:
On Cygwin if the glob-string contains backslashes as well, causing a warning (Cygwin >= 1.7):
MS-DOS style path detected: ...
Preferred POSIX equivalent is: ...
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
On Linux, using strace, you can see bash-completion doing an unnecessary `open' system call.
Steps to reproduce on Linux using `strace':
Environment: Linux, bash-completion-1.0
1. Start bash with bash-completion loaded and find out PID ($$):
$ echo $$
MYPID
2. In a second bash shell, `strace' the above PID:
$ strace -e trace=open -f -o strace.log -p MYPID
3. Within the first bash shell, type:
$ cur="?"; _kernel_versions
4. In the second bash shell, type ^C to quick `strace'.
5. Check `strace.log', here you can see bash accessing
something it shouldn't:
...
open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
...
6. The above call to `open' disappears if $cur in _kernel_versions gets
quoted, and you repeat the steps above:
_kernel_versions()
{
COMPREPLY=( $( compgen -W '$( command ls /lib/modules )' -- "$cur" ) )
}
Diffstat (limited to 'contrib/shadow')
-rw-r--r-- | contrib/shadow | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/contrib/shadow b/contrib/shadow index 84164f67..0c150a33 100644 --- a/contrib/shadow +++ b/contrib/shadow @@ -29,12 +29,12 @@ _useradd() _gids [ -n "$bash205" ] && \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -g ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) return 0 ;; -G|--groups) [ -n "$bash205" ] && \ - COMPREPLY=( $( compgen -g -- $cur ) ) + COMPREPLY=( $( compgen -g -- "$cur" ) ) return 0 ;; -s|--shell) @@ -51,7 +51,7 @@ _useradd() -G --groups -h --help -k --skel -K --key -l -M \ -m --create-home -N --no-user-group -o --non-unique \ -p --password -r --system -s --shell -u --uid \ - -U --user-group -Z --selinux-user' -- $cur ) ) + -U --user-group -Z --selinux-user' -- "$cur" ) ) return 0 fi } && @@ -79,12 +79,12 @@ _usermod() _gids [ -n "$bash205" ] && \ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -g ) ) - COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- $cur ) ) + COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) return 0 ;; -G|--groups) [ -n "$bash205" ] && \ - COMPREPLY=( $( compgen -g -- $cur ) ) + COMPREPLY=( $( compgen -g -- "$cur" ) ) return 0 ;; -s|--shell) @@ -101,11 +101,11 @@ _usermod() -e --expiredate -f --inactive -g --gid -G --groups \ -h --help -l --login -L --lock -o --non-unique \ -p --password -s --shell -u --uid -U --unlock \ - -Z --selinux-user' -- $cur ) ) + -Z --selinux-user' -- "$cur" ) ) return 0 fi - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _usermod usermod @@ -119,11 +119,11 @@ _userdel() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-f --force -h --help -r --remove' \ - -- $cur ) ) + -- "$cur" ) ) return 0 fi - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _userdel userdel @@ -149,11 +149,11 @@ _chage() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-d --lastday -E --expiredate \ -h --help -I --inactive -l --list -m --mindays \ - -M --maxdays -W --warndays' -- $cur ) ) + -M --maxdays -W --warndays' -- "$cur" ) ) return 0 fi - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _chage chage @@ -174,11 +174,11 @@ _passwd() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-k -l --stdin -u -d -n -x -w -i -S \ - -? --help --usage' -- $cur ) ) + -? --help --usage' -- "$cur" ) ) return 0 fi - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) } && complete -F _passwd passwd @@ -196,7 +196,7 @@ _chpasswd() case "$prev" in -c|--crypt) COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ - -- $cur ) ) + -- "$cur" ) ) return 0 ;; -s|--sha-rounds) @@ -208,7 +208,7 @@ _chpasswd() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-c --crypt-method -e --encrypted \ - -h --help -m --md5 -s --sha-rounds' -- $cur ) ) + -h --help -m --md5 -s --sha-rounds' -- "$cur" ) ) return 0 fi } && @@ -228,7 +228,7 @@ _newusers() case "$prev" in -c|--crypt) COMPREPLY=( $( compgen -W 'DES MD5 NONE SHA256 SHA512' \ - -- $cur ) ) + -- "$cur" ) ) return 0 ;; -s|--sha-rounds) @@ -240,7 +240,7 @@ _newusers() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-c --crypt-method --r --system \ - -s --sha-rounds' -- $cur ) ) + -s --sha-rounds' -- "$cur" ) ) return 0 fi @@ -257,7 +257,7 @@ _pwck() cur=`_get_cword` if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-q -r -s' -- $cur ) ) + COMPREPLY=( $( compgen -W '-q -r -s' -- "$cur" ) ) return 0 fi @@ -290,7 +290,7 @@ _groupadd() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-f --force -g --gid -h --help \ -K --key -o --non-unique -p --password -r --system' \ - -- $cur ) ) + -- "$cur" ) ) return 0 fi } && @@ -320,11 +320,11 @@ _groupmod() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-g --gid -h --help -n --new-name \ - -o --non-unique -p --password' -- $cur ) ) + -o --non-unique -p --password' -- "$cur" ) ) return 0 fi - [ -n "$bash205" ] && COMPREPLY=( $( compgen -g -- $cur ) ) + [ -n "$bash205" ] && COMPREPLY=( $( compgen -g -- "$cur" ) ) } && complete -F _groupmod groupmod @@ -351,17 +351,17 @@ _gpasswd() case "$prev" in -a|-d|-A|-M) - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -d -r -R -A -M' -- $cur ) ) + COMPREPLY=( $( compgen -W '-a -d -r -R -A -M' -- "$cur" ) ) return 0 fi - [ -n "$bash205" ] && COMPREPLY=( $( compgen -g -- $cur ) ) + [ -n "$bash205" ] && COMPREPLY=( $( compgen -g -- "$cur" ) ) } && complete -F _gpasswd gpasswd @@ -376,18 +376,18 @@ _groupmems() case "$prev" in -a|-d) - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) return 0 ;; -g) [ -n "$bash205" ] && \ - COMPREPLY=( $( compgen -g -- $cur ) ) + COMPREPLY=( $( compgen -g -- "$cur" ) ) return 0 ;; esac if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-a -d -p -g -l' -- $cur ) ) + COMPREPLY=( $( compgen -W '-a -d -p -g -l' -- "$cur" ) ) return 0 fi } && @@ -402,7 +402,7 @@ _grpck() cur=`_get_cword` if [[ "$cur" == -* ]]; then - COMPREPLY=( $( compgen -W '-r -s' -- $cur ) ) + COMPREPLY=( $( compgen -W '-r -s' -- "$cur" ) ) return 0 fi @@ -427,7 +427,7 @@ _vipw() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-g --group -h --help -p --passwd \ - -q --quiet -s --shadow' -- $cur ) ) + -q --quiet -s --shadow' -- "$cur" ) ) return 0 fi } && @@ -449,7 +449,7 @@ _faillog() return 0 ;; -u|--user) - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) return 0 ;; esac @@ -458,7 +458,7 @@ _faillog() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-a --all -h --help -l --lock-time \ - -m --maximum -r --reset -t --time -u --user' -- $cur ) ) + -m --maximum -r --reset -t --time -u --user' -- "$cur" ) ) return 0 fi } && @@ -480,7 +480,7 @@ _lastlog() return 0 ;; -u|--user) - COMPREPLY=( $( compgen -u -- $cur ) ) + COMPREPLY=( $( compgen -u -- "$cur" ) ) return 0 ;; esac @@ -489,7 +489,7 @@ _lastlog() if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W '-b --before -h --help -t --time \ - -u --user' -- $cur ) ) + -u --user' -- "$cur" ) ) return 0 fi } && |