Skip to content

Commit 6f5ec1b

Browse files
authored
Merge pull request scop#670 from akinomyoga/fix-failglob-for-_expand
Fix `_expand` for failglob
2 parents b0afc79 + 0de8dea commit 6f5ec1b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

bash_completion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ _expand()
12091209
;;
12101210
~*)
12111211
_tilde "$cur" ||
1212-
eval COMPREPLY[0]="$(printf ~%q "${COMPREPLY[0]#\~}")"
1212+
eval "COMPREPLY[0]=$(printf ~%q "${COMPREPLY[0]#\~}")"
12131213
return ${#COMPREPLY[@]}
12141214
;;
12151215
esac

test/t/unit/test_unit_expand.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from conftest import assert_bash_exec
3+
from conftest import assert_bash_exec, bash_env_saved
44

55

66
@pytest.mark.bashcomp(cmd=None, ignore_env=r"^[+-](cur|COMPREPLY)=")
@@ -21,6 +21,17 @@ def test_user_home_compreply(self, bash, user_home):
2121
)
2222
assert output.strip() == home
2323

24+
def test_user_home_compreply_failglob(self, bash, user_home):
25+
user, home = user_home
26+
with bash_env_saved(bash) as bash_env:
27+
bash_env.shopt("failglob", True)
28+
output = assert_bash_exec(
29+
bash,
30+
r'cur="~%s"; _expand; printf "%%s\n" "$COMPREPLY"' % user,
31+
want_output=True,
32+
)
33+
assert output.strip() == home
34+
2435
def test_user_home_cur(self, bash, user_home):
2536
user, home = user_home
2637
output = assert_bash_exec(

0 commit comments

Comments
 (0)