diff options
author | Norbert Lange <nolange79@gmail.com> | 2022-05-24 22:26:29 +0200 |
---|---|---|
committer | Matthew Martin <phy1729@gmail.com> | 2022-05-25 22:50:48 -0500 |
commit | c1f1bbc5b9c128944b82afed25140ee62ccf522a (patch) | |
tree | d297ce494674cd5aba7d7b65ffdb9472255a839c | |
parent | 1e52cd968d7ffd9da3249ef01f6c41f8b29e4df3 (diff) | |
download | zsh-c1f1bbc5b9c128944b82afed25140ee62ccf522a.tar.gz zsh-c1f1bbc5b9c128944b82afed25140ee62ccf522a.tar.xz zsh-c1f1bbc5b9c128944b82afed25140ee62ccf522a.zip |
github #93: Replace /etc/mtab with /proc/self/mounts for Linux
/proc/self/mounts has been available since Linux 2.4.19, released in 2002. /etc/mtab is usually a symlink to this file but might not exist
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Completion/Linux/Command/_btrfs | 2 | ||||
-rw-r--r-- | Completion/Linux/Command/_fusermount | 2 | ||||
-rw-r--r-- | Completion/Unix/Type/_umountable | 7 |
4 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog index b2cecc1a3..f82e492f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2022-05-25 Norbert Lange <nolange79@gmail.com> + + * github #93: Completion/Linux/Command/_btrfs, + Completion/Linux/Command/_fusermount, + Completion/Unix/Type/_umountable: Replace /etc/mtab with + /proc/self/mounts for Linux. + 2022-05-22 Bart Schaefer <schaefer@zsh.org> * 50278: Completion/Unix/Command/_man: use `man -w` in preference diff --git a/Completion/Linux/Command/_btrfs b/Completion/Linux/Command/_btrfs index 65cf067aa..1d87fd83a 100644 --- a/Completion/Linux/Command/_btrfs +++ b/Completion/Linux/Command/_btrfs @@ -424,7 +424,7 @@ while (( $#state )); do ;; mounts) _wanted mount-points expl 'mount point' compadd \ - ${${${(M)${(f)"$(</etc/mtab)"}:#*btrfs*}#* }%% *} && ret=0 + ${${${(M)${(f)"$(</proc/self/mounts)"}:#*btrfs*}#* }%% *} && ret=0 ;; filters) state=() diff --git a/Completion/Linux/Command/_fusermount b/Completion/Linux/Command/_fusermount index 41d3dec72..d55eca29c 100644 --- a/Completion/Linux/Command/_fusermount +++ b/Completion/Linux/Command/_fusermount @@ -19,7 +19,7 @@ case "$state" in if [[ $+opt_args[-u] -eq 0 ]]; then _files -/ else - mtpts=(${${${"${(f)$(< /etc/mtab)}"}#* }%% *}) + mtpts=(${${${"${(f)$(< /proc/self/mounts)}"}#* }%% *}) _canonical_paths mounted 'mounted filesystem' "${(@g::)mtpts}" fi ;; diff --git a/Completion/Unix/Type/_umountable b/Completion/Unix/Type/_umountable index 7ffce5bb4..6e4988e2d 100644 --- a/Completion/Unix/Type/_umountable +++ b/Completion/Unix/Type/_umountable @@ -3,7 +3,12 @@ local tmp local dev_tmp dpath_tmp mp_tmp mline case "$OSTYPE" in -linux*|irix*) +linux*) + tmp=( "${(@f)$(< /proc/self/mounts)}" ) + dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) + mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) + ;; +irix*) tmp=( "${(@f)$(< /etc/mtab)}" ) dev_tmp=( "${(@)${(@)tmp%% *}:#none}" ) mp_tmp=( "${(@)${(@)tmp#* }%% *}" ) |