Skip to content

Commit

Permalink
bzip2, gzip, and other compressors: Use _tilde instead of _expand
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Mar 16, 2018
1 parent ec85ac4 commit 3c4fc36
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion completions/bzip2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _bzip2()
[[ "$prev" == -*z* ]] && xspec=
fi

_expand || return
_tilde "$cur" || return

compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
Expand Down
2 changes: 1 addition & 1 deletion completions/gzip
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ _gzip()
[[ "$prev" == -*f* ]] && xspec=
fi

_expand || return
_tilde "$cur" || return

compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
Expand Down
4 changes: 2 additions & 2 deletions completions/lrzip
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ _lrzip()
;;
esac

_expand || return

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
return
fi

_tilde "$cur" || return

local IFS=$'\n'
compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
Expand Down
3 changes: 2 additions & 1 deletion completions/lz4
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ _lz4()
esac
done

_expand || return
_tilde "$cur" || return

local IFS=$'\n'
compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
Expand Down
2 changes: 1 addition & 1 deletion completions/lzma
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _lzma()
[[ "$prev" == -*z* ]] && xspec=
fi

_expand || return
_tilde "$cur" || return

compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
Expand Down
2 changes: 1 addition & 1 deletion completions/lzop
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ _lzop()
;;
esac

_expand || return
_tilde "$cur" || return

local IFS=$'\n'
compopt -o filenames
Expand Down
4 changes: 2 additions & 2 deletions completions/xz
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ _xz()

$split && return

_expand || return

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --long-help ) {-1..-9}' \
-- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi

_tilde "$cur" || return

local IFS=$'\n'
compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
Expand Down
5 changes: 2 additions & 3 deletions completions/zopfli
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ _zopfli()
return
fi

local IFS=$'\n' xspec="*.@(gz|t[ag]z)"

_expand || return
_tilde "$cur" || return

local IFS=$'\n' xspec="*.@(gz|t[ag]z)"
compopt -o filenames
COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
$( compgen -d -- "$cur" ) )
Expand Down
4 changes: 4 additions & 0 deletions test/lib/completions/bzip2.exp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ assert_complete_any "bzip2 "
sync_after_int


assert_complete_homedir "bzip"
sync_after_int


teardown
4 changes: 4 additions & 0 deletions test/lib/completions/gzip.exp
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ expect {
sync_after_int


assert_complete_homedir "gzip"
sync_after_int


teardown
4 changes: 4 additions & 0 deletions test/lib/completions/lrzip.exp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ assert_complete_any "lrzip "
sync_after_int


assert_complete_homedir "lrzip"
sync_after_int


teardown
3 changes: 3 additions & 0 deletions test/lib/completions/lz4.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ setup
assert_complete_any "lz4 "
sync_after_int

assert_complete_homedir "lz4"
sync_after_int


teardown
4 changes: 4 additions & 0 deletions test/lib/completions/lzma.exp
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ assert_complete "a/ bashcomp.lzma bashcomp.tlz" "lzma -d $::srcdir/fixtures/xz/"
sync_after_int


assert_complete_homedir "lzma"
sync_after_int


teardown
4 changes: 4 additions & 0 deletions test/lib/completions/lzop.exp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ assert_complete_any "lzop "
sync_after_int


assert_complete_homedir "lzop"
sync_after_int


teardown
4 changes: 4 additions & 0 deletions test/lib/completions/xz.exp
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ assert_complete_dir "a/ bashcomp.tar" "xz " $::srcdir/fixtures/xz
sync_after_int


assert_complete_homedir "xz"
sync_after_int


teardown
4 changes: 4 additions & 0 deletions test/lib/completions/zopfli.exp
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ assert_complete_any "zopfli "
sync_after_int


assert_complete_homedir "zopfli"
sync_after_int


teardown

0 comments on commit 3c4fc36

Please sign in to comment.