summaryrefslogtreecommitdiff
path: root/completions/_umount.linux
diff options
context:
space:
mode:
Diffstat (limited to 'completions/_umount.linux')
-rw-r--r--completions/_umount.linux52
1 files changed, 27 insertions, 25 deletions
diff --git a/completions/_umount.linux b/completions/_umount.linux
index 59727b4b..cf8a2595 100644
--- a/completions/_umount.linux
+++ b/completions/_umount.linux
@@ -15,7 +15,7 @@ _reply_compgen_array()
# argument.
local i wlist
for i in ${!COMPREPLY[*]}; do
- local q=$(quote "$(printf %q "${COMPREPLY[$i]}")")
+ local q=$(quote "$(printf %q "${COMPREPLY[i]}")")
wlist+=$q$'\n'
done
@@ -25,13 +25,14 @@ _reply_compgen_array()
ecur=${ecur//\'/\\\'}
# Actually generate completions.
- local oldifs=$IFS
+ local ifs=$IFS
IFS=$'\n' eval 'COMPREPLY=(`compgen -W "$wlist" -- "${ecur}"`)'
- IFS=$oldifs
+ IFS=$ifs
}
# Unescape strings in the linux fstab(5) format (with octal escapes).
-__linux_fstab_unescape() {
+__linux_fstab_unescape()
+{
eval $1="'${!1//\'/\\047}'"
eval $1="'${!1/%\\/\\\\}'"
eval "$1=$'${!1}'"
@@ -40,23 +41,24 @@ __linux_fstab_unescape() {
# Complete linux fstab entries.
#
# Reads a file from stdin in the linux fstab(5) format; as used by /etc/fstab
-# and /proc/mounts.
+# and /proc/mounts. With 1st arg -L, look for entries by label.
+# shellcheck disable=SC2120
_linux_fstab()
{
COMPREPLY=()
# Read and unescape values into COMPREPLY
local fs_spec fs_file fs_other
- local oldifs="$IFS"
+ local ifs="$IFS"
while read -r fs_spec fs_file fs_other; do
if [[ $fs_spec == [#]* ]]; then continue; fi
- if [[ $1 == -L ]]; then
- local fs_label=${fs_spec/#LABEL=}
+ if [[ ${1-} == -L ]]; then
+ local fs_label=${fs_spec/#LABEL=/}
if [[ $fs_label != "$fs_spec" ]]; then
__linux_fstab_unescape fs_label
IFS=$'\0'
COMPREPLY+=("$fs_label")
- IFS=$oldifs
+ IFS=$ifs
fi
else
__linux_fstab_unescape fs_spec
@@ -64,7 +66,7 @@ _linux_fstab()
IFS=$'\0'
[[ $fs_spec == */* ]] && COMPREPLY+=("$fs_spec")
[[ $fs_file == */* ]] && COMPREPLY+=("$fs_file")
- IFS=$oldifs
+ IFS=$ifs
fi
done
@@ -81,12 +83,12 @@ _linux_fstab()
dircur="${cur%/*}/"
fi
basecur=${cur#"$dircur"}
- local i n=${#COMPREPLY[@]}
- for (( i=0; i < $n; i++ )); do
- [[ "${COMPREPLY[i]}" == "$realcur"* ]] &&
- COMPREPLY+=( $(cd "$dircur" 2>/dev/null &&
+ local i
+ for i in ${!COMPREPLY[*]}; do
+ [[ ${COMPREPLY[i]} == "$realcur"* ]] &&
+ COMPREPLY+=($(cd "$dircur" 2>/dev/null &&
compgen -f -d -P "$dircur" \
- -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur") )
+ -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur"))
done
fi
fi
@@ -103,18 +105,18 @@ _umount()
-t)
# FIXME: no<fstype>
local split=false
- if [[ "$cur" == ?*,* ]]; then
+ if [[ $cur == ?*,* ]]; then
prev="${cur%,*}"
cur="${cur##*,}"
split=true
fi
- COMPREPLY=( $(compgen -W 'adfs affs autofs btrfs cifs coda
+ COMPREPLY=($(compgen -W 'adfs affs autofs btrfs cifs coda
cramfs debugfs devpts efs ext2 ext3 ext4 fuse hfs hfsplus hpfs
iso9660 jfs minix msdos ncpfs nfs nfs4 ntfs ntfs-3g proc qnx4
ramfs reiserfs romfs squashfs smbfs sysv tmpfs ubifs udf ufs
- umsdos usbfs vfat xfs' -- "$cur") )
+ umsdos usbfs vfat xfs' -- "$cur"))
_fstypes
- $split && COMPREPLY=( ${COMPREPLY[@]/#/$prev,} )
+ $split && COMPREPLY=(${COMPREPLY[@]/#/$prev,})
return
;;
-O)
@@ -123,10 +125,10 @@ _umount()
;;
esac
- if [[ "$cur" == -* ]]; then
- COMPREPLY=( $(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l
- --no-canonicalize --fake' -- "$cur") )
- [[ $COMPREPLY ]] && return
+ if [[ $cur == -* ]]; then
+ COMPREPLY=($(compgen -W '-V -h -v -n -r -d -i -a -t -O -f -l
+ --no-canonicalize --fake' -- "$cur"))
+ [[ ${COMPREPLY-} ]] && return
fi
if [[ -r /proc/mounts ]]; then
@@ -135,9 +137,9 @@ _umount()
_linux_fstab </proc/mounts
else
local IFS=$'\n'
- COMPREPLY=( $(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur") )
+ COMPREPLY=($(compgen -W '$(mount | cut -d" " -f 3)' -- "$cur"))
fi
} &&
-complete -F _umount -o dirnames umount
+ complete -F _umount -o dirnames umount
# ex: filetype=sh