[Bash-completion-commits] [SCM] bash-completion branch, mount, updated. 1.90-54-g0b93515
Igor Murzov
e-mail at date.by
Sun Dec 4 13:54:10 UTC 2011
The following commit has been merged in the mount branch:
commit 54bcdff3cf7e7e40f7ae0f4f20b53287653aa233
Author: Igor Murzov <e-mail at date.by>
Date: Sun Dec 4 05:34:25 2011 +0400
umount: Real fix for completion of relative paths.
diff --git a/completions/umount.linux b/completions/umount.linux
index 3fbd544..9723180 100644
--- a/completions/umount.linux
+++ b/completions/umount.linux
@@ -65,16 +65,27 @@ _linux_fstab()
fi
done
- # Add some relative paths to COMPREPLY
+ # Add relative paths to COMPREPLY
if [[ $cur && $cur != /* ]]; then
- local i n=${#COMPREPLY[@]}
- for (( i=0; i < $n; i++ )); do
- if [[ "${COMPREPLY[i]}" == "$PWD"* ]]; then
- [[ $cur == ./* ]] &&
- COMPREPLY+=( "./${COMPREPLY[i]##$PWD*(/)}" ) ||
- COMPREPLY+=( "${COMPREPLY[i]##$PWD*(/)}" )
+ local realcur
+ [[ $cur == */ ]] && # don't let readlink drop last / from path
+ realcur="$( readlink -f "$cur." 2> /dev/null )/" ||
+ realcur=$( readlink -f "$cur" 2> /dev/null )
+ if [[ $realcur ]]; then
+ local dirrealcur= dircur= basecur
+ if [[ $cur == */* ]]; then
+ dirrealcur="${realcur%/*}/"
+ dircur="${cur%/*}/"
fi
- done
+ basecur=${cur#"$dircur"}
+ local i n=${#COMPREPLY[@]}
+ for (( i=0; i < $n; i++ )); do
+ [[ "${COMPREPLY[i]}" == "$realcur"* ]] &&
+ COMPREPLY+=( $( cd "$dircur" 2> /dev/null &&
+ compgen -f -d -P "$dircur" \
+ -X "!${COMPREPLY[i]##"$dirrealcur"}" -- "$basecur" ) )
+ done
+ fi
fi
_reply_compgen_array
--
bash-completion
More information about the Bash-completion-commits
mailing list