@@ -850,7 +850,7 @@ _comp_quote_compgen()
850850#
851851_comp_compgen_filedir ()
852852{
853- _tilde " ${cur-} " || return
853+ _comp_compgen_tilde && return
854854
855855 local -a toks
856856 local arg=${1-}
@@ -1458,21 +1458,21 @@ _ncpus()
14581458}
14591459
14601460# Perform tilde (~) completion
1461- # @return True (0 ) if completion needs further processing,
1462- # False (1 ) if tilde is followed by a valid username, completions are
1461+ # @return False (1 ) if completion needs further processing,
1462+ # True (0 ) if tilde is followed by a valid username, completions are
14631463# put in COMPREPLY and no further processing is necessary.
1464- # TODO: rename per API conventions
1465- _tilde ()
1464+ _comp_compgen_tilde ()
14661465{
1467- if [[ ${1 -} == \~ * && $1 != * /* ]]; then
1466+ if [[ ${cur -} == \~ * && $cur != * /* ]]; then
14681467 # Try generate ~username completions
1469- if _comp_compgen -c " ${1# \~ } " -- -P ' ~' -u; then
1470- # 2>/dev/null for direct invocation, e.g. in the _tilde unit test
1468+ if _comp_compgen -c " ${cur# \~ } " -- -P ' ~' -u; then
1469+ # 2>/dev/null for direct invocation, e.g. in the
1470+ # _comp_compgen_tilde unit test
14711471 compopt -o filenames 2> /dev/null
1472- return 1
1472+ return 0
14731473 fi
14741474 fi
1475- return 0
1475+ return 1
14761476}
14771477
14781478# Expand variable starting with tilde (~)
@@ -1519,7 +1519,7 @@ _expand()
15191519 __expand_tilde_by_ref cur
15201520 ;;
15211521 ~ * )
1522- _tilde " $cur " ||
1522+ _comp_compgen -v COMPREPLY tilde &&
15231523 eval " COMPREPLY[0]=$( printf ~ %q " ${COMPREPLY[0]# \~ } " ) "
15241524 return ${# COMPREPLY[@]}
15251525 ;;
@@ -2556,7 +2556,7 @@ _filedir_xspec()
25562556 local cur prev words cword comp_args
25572557 _comp_initialize -- " $@ " || return
25582558
2559- _tilde " $cur " || return
2559+ _comp_compgen_tilde && return
25602560
25612561 local ret
25622562 _comp_quote_compgen " $cur "
0 commit comments