Skip to content

Commit

Permalink
ulimit: improvements when -a is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 14, 2019
1 parent 2bf12d7 commit 6bc7bba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 13 additions & 3 deletions completions/ulimit
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ _ulimit()
local cur prev words cword
_init_completion || return

# TODO combined option support (-aH, -Sc etc)

local mode
case $prev in
-a)
COMPREPLY=( $( compgen -W "-S -H" -- "$cur" ) )
return
;;
-[SH])
Expand All @@ -17,9 +20,16 @@ _ulimit()
;;
esac

if [[ -z "$mode" && "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_usage "$1" )' -- "$cur" ) )
return
if [[ -z "$mode" ]]; then
local word
for word in "${words[@]}"; do
[[ $word == -*a* ]] && return
done

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

local args
Expand Down
5 changes: 5 additions & 0 deletions test/t/test_ulimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ def test_5(self, completion):

@pytest.mark.complete("ulimit -a ")
def test_6(self, completion):
assert completion == sorted("-S -H".split())

@pytest.mark.complete("ulimit -a -H -")
def test_7(self, completion):
"""Test modes are NOT completed with -a given somewhere."""
assert not completion

0 comments on commit 6bc7bba

Please sign in to comment.