Skip to content

Commit 52419c0

Browse files
authored
Merge pull request #1073 from akinomyoga/fix832
fix(_comp_initialize): fix completions of redirections without space
2 parents b545d7d + 571a0f7 commit 52419c0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bash_completion

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ _comp_delimited()
11991199
delimiter=$1
12001200
shift
12011201
fi
1202-
[[ $cur == *$delimiter* ]] && prefix=${cur%"$delimiter"*}$delimiter
1202+
[[ $cur == *"$delimiter"* ]] && prefix=${cur%"$delimiter"*}$delimiter
12031203

12041204
if [[ $deduplicate ]]; then
12051205
# We could construct a -X pattern to feed to compgen, but that'd
@@ -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)