File tree Expand file tree Collapse file tree 12 files changed +53
-15
lines changed Expand file tree Collapse file tree 12 files changed +53
-15
lines changed Original file line number Diff line number Diff line change @@ -390,6 +390,14 @@ _comp_expand_glob()
390390 return 0
391391}
392392
393+ # Check if the argument looks like a path.
394+ # @param $1 thing to check
395+ # @return True (0) if it does, False (> 0) otherwise
396+ _comp_looks_like_path ()
397+ {
398+ [[ ${1-} == @ (* /| [.~])* ]]
399+ }
400+
393401# Reassemble command line words, excluding specified characters from the
394402# list of word completion separators (COMP_WORDBREAKS).
395403# @param $1 chars Characters out of $COMP_WORDBREAKS which should
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ _apt_get()
3939 awk ' $1 == "Source:" { print $2 }' | sort -u) " -- " $cur " ) )
4040 ;;
4141 install | reinstall)
42- if [[ $cur == * / * ]] ; then
42+ if _comp_looks_like_path " $cur " ; then
4343 _filedir deb
4444 return
4545 elif [[ $cur == * = * ]]; then
@@ -58,7 +58,7 @@ _apt_get()
5858 ;;&
5959 build-dep)
6060 _filedir -d
61- [[ $cur != * / * ]] || return
61+ _comp_looks_like_path " $cur " && return
6262 ;;&
6363 * )
6464 COMPREPLY+=($( _comp_xfunc apt-cache packages) )
Original file line number Diff line number Diff line change 1717 if (( cword == 1 )) ; then
1818 local IFS
1919 compopt -o filenames
20- if [[ $cur == * / * ]] ; then
20+ if _comp_looks_like_path " $cur " ; then
2121 # compgen -c works as expected if $cur contains any slashes.
2222 IFS=$' \n '
2323 COMPREPLY=($( PATH=" $PATH :." compgen -d -c -- " $cur " ) )
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ _kldload()
77 local cur prev words cword
88 _init_completion || return
99
10- if [[ " $cur " == * / * ]] ; then
10+ if _comp_looks_like_path " $cur " ; then
1111 _filedir ko
1212 return
1313 fi
Original file line number Diff line number Diff line change 5252 fi
5353
5454 # file based completion if parameter looks like a path
55- if [[ $cur == @ ( * / | [.~]) * ]] ; then
55+ if _comp_looks_like_path " $cur " ; then
5656 _filedir " $manext "
5757 return
5858 fi
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ _pydoc()
2424
2525 COMPREPLY=($( compgen -W ' keywords topics modules' -- " $cur " ) )
2626
27- if [[ $cur != @ (. | * /) * ]] ; then
27+ if ! _comp_looks_like_path " $cur " ; then
2828 local python=python
2929 [[ ${1##*/ } == * 3* ]] && python=python3
3030 _comp_xfunc python modules $python
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ _pylint()
107107 return
108108 fi
109109
110- [[ $cur == @ (. | * /) * ]] || _comp_xfunc python modules $python
110+ _comp_looks_like_path " $cur " || _comp_xfunc python modules $python
111111 _filedir py
112112} &&
113113 complete -F _pylint pylint pylint-2 pylint-3
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ _removepkg()
99 return
1010 fi
1111
12- if [[ $cur == * / * ]] ; then
12+ if _comp_looks_like_path " $cur " ; then
1313 _filedir
1414 return
1515 fi
Original file line number Diff line number Diff line change 9292 ;;
9393 --whatenhances | --whatprovides | --whatrecommends | --whatrequires | \
9494 --whatsuggests | --whatsupplements)
95- if [[ $cur == * / * ]] ; then
95+ if _comp_looks_like_path " $cur " ; then
9696 _filedir
9797 else
9898 # complete on capabilities
Original file line number Diff line number Diff line change @@ -580,12 +580,11 @@ _scp()
580580 COMPREPLY=(" ${COMPREPLY[@]/%/ } " )
581581 return
582582 ;;
583- * /* | [.~]* )
584- # not a known host, pass through
585- ;;
586583 * )
587- _known_hosts_real ${ipvx-} -c -a \
588- ${configfile: +-F " $configfile " } -- " $cur "
584+ if ! _comp_looks_like_path " $cur " ; then
585+ _known_hosts_real ${ipvx-} -c -a \
586+ ${configfile: +-F " $configfile " } -- " $cur "
587+ fi
589588 ;;
590589 esac
591590 fi
You can’t perform that action at this time.
0 commit comments