Skip to content

Commit

Permalink
fix(_comp_initialize): fix completions of redirections without space
Browse files Browse the repository at this point in the history
This is a regression by commit 38150db.  Although the shellcheck
issues a warning SC2295, $redir is intensionally a pattern here.

Fixes #832
  • Loading branch information
akinomyoga committed Nov 28, 2023
1 parent b545d7d commit da16bf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1382,7 +1382,8 @@ _comp_initialize()
esac
;;
esac
cur=${cur##"$redir"}
# shellcheck disable=SC2295 # redir is a pattern
cur=${cur##$redir}
_comp_compgen_filedir "$xspec"
return 1
fi
Expand Down
7 changes: 7 additions & 0 deletions test/t/unit/test_unit_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ def test_redirect_2(self, bash, cmd1_empty_completion_setup, redirect):
bash, "cmd1 %s f" % redirect, cwd="shared/default"
)
assert "foo" in completion

@pytest.mark.parametrize("redirect", "> >> 2> < &>".split())
def test_redirect_3(self, bash, redirect):
completion = assert_complete(
bash, "cmd1 %sf" % redirect, cwd="shared/default"
)
assert "foo" in completion

0 comments on commit da16bf6

Please sign in to comment.