Skip to content

Commit da16bf6

Browse files
committed
fix(_comp_initialize): fix completions of redirections without space
This is a regression by commit 38150db. Although the shellcheck issues a warning SC2295, $redir is intensionally a pattern here. Fixes #832
1 parent b545d7d commit da16bf6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

bash_completion

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,8 @@ _comp_initialize()
13821382
esac
13831383
;;
13841384
esac
1385-
cur=${cur##"$redir"}
1385+
# shellcheck disable=SC2295 # redir is a pattern
1386+
cur=${cur##$redir}
13861387
_comp_compgen_filedir "$xspec"
13871388
return 1
13881389
fi

test/t/unit/test_unit_initialize.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,10 @@ def test_redirect_2(self, bash, cmd1_empty_completion_setup, redirect):
5757
bash, "cmd1 %s f" % redirect, cwd="shared/default"
5858
)
5959
assert "foo" in completion
60+
61+
@pytest.mark.parametrize("redirect", "> >> 2> < &>".split())
62+
def test_redirect_3(self, bash, redirect):
63+
completion = assert_complete(
64+
bash, "cmd1 %sf" % redirect, cwd="shared/default"
65+
)
66+
assert "foo" in completion

0 commit comments

Comments
 (0)