Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions completions/sha256sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ _comp_cmd_sha256sum()

local sumtype=${1##*/}
sumtype=${sumtype%sum}
local sumglob="@(*.$sumtype|@(check|${sumtype})sums?(.txt))"
compopt -o filenames

local opt
for opt in "${words[@]}"; do
if [[ $opt == -@(c|-check) ]]; then
_comp_compgen_filedir "$sumtype"
_comp_compgen -- -f -X "!$sumglob" -o plusdirs
return
fi
done

local files
_comp_compgen -v files filedir &&
_comp_compgen -- -X "*.$sumtype" -W '"${files[@]}"'
_comp_compgen -- -f -X "$sumglob" -o plusdirs
} &&
complete -F _comp_cmd_sha256sum b2sum cksum md5sum \
sha{,1,224,256,384,512}sum
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/sha256sum/checksums
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 foo
1 change: 1 addition & 0 deletions test/fixtures/sha256sum/checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 foo
Empty file.
1 change: 1 addition & 0 deletions test/fixtures/sha256sum/sha256sums
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 foo
1 change: 1 addition & 0 deletions test/fixtures/sha256sum/sha256sums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 foo
11 changes: 9 additions & 2 deletions test/t/test_sha256sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ def test_options(self, completion):

@pytest.mark.complete("sha256sum ", cwd="sha256sum")
def test_summing(self, completion):
assert completion == "foo"
assert completion == ["dir/", "foo"]

@pytest.mark.complete("sha256sum -c ", cwd="sha256sum")
def test_checking(self, completion):
assert completion == "foo.sha256"
assert completion == [
"checksums",
"checksums.txt",
"dir/",
"foo.sha256",
"sha256sums",
"sha256sums.txt",
]