Bash completion breaks with single-quote
Dacoda Strack
dacoda.strack at gmail.com
Sat Mar 20 23:56:12 UTC 2021
I am curious if anyone else has had issues with single-quotes in
filenames. For example, consider the following directory:
```
# tree ~/.password-store/Quote\ Example/
/home/dacoda/.password-store/Quote Example/
├── Alice's
│ └── Very Secret.gpg
└── Mine
└── Very Secret.gpg
2 directories, 2 files
```
When I attempt to autocomplete `pass -c Quote\ Example/Mi`, it works
brilliantly and completes me all the way down to:
`Quote\ Example/Mine/Very\ Secret`
On the other hand, with Alice, attempting to autocomplete similarly with
`pass -c Quote\ Example/Alice\'s/` fails out. I noticed that passing
this `-o default` option to compgen helps me here, though I am unsure of
other ramifications.
Please see below an excerpt from the bash man page, and a thread from
the bash mailing list regarding other people's reckoning of the issue.
Has this issue already been discussed in the mailing lists? Any comments
or insight would be greatly appreciated.
Thank you for the excellent tool.
```
-o comp-option
The comp-option controls several aspects of the compspec's behavior
beyond the simple generation of completions. comp-option may be one
of:
...
default Use readline's default filename completion if the compspec
generates no matches.
```
https://lists.gnu.org/archive/html/bug-bash/2011-10/msg00059.html
-- >8 --
Subject: [PATCH] pass '-o default' to compgen to properly handle single-quotes
---
src/completion/pass.bash-completion | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/completion/pass.bash-completion b/src/completion/pass.bash-completion
index 95d3e1e..4e921cf 100644
--- a/src/completion/pass.bash-completion
+++ b/src/completion/pass.bash-completion
@@ -11,7 +11,7 @@ _pass_complete_entries () {
local autoexpand=${1:-0}
local IFS=$'\n'
- local items=($(compgen -f $prefix$cur))
+ local items=($(compgen -o default -f $prefix$cur))
# Remember the value of the first item, to see if it is a directory. If
# it is a directory, then don't add a space to the completion
--
2.29.2
More information about the Password-Store
mailing list