- Package:
- bash-completion
- Source:
- bash-completion
- Submitter:
- Helmut Grohne
- Date:
- 2018-12-12 22:39:09 UTC
- Severity:
- normal
After upgrading 1:1.2-3 to 1:1.3-1 mutt aliases stopped to be complete. Now it
only completes users from /etc/passwd. Thanks to etckeeper the older version
was easily recovered. The diff to /etc/bash_completion.d/mutt consists of just
three hunks of which the following hunk is the offending one:
@@ -58,7 +61,7 @@ _muttconffiles()
while [[ "$1" ]]; do
newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) )
for file in "${newconffiles[@]}"; do
- [[ ! "$file" ]] || [[ "${sofar/ ${file} / }" != "$sofar" ]] &&
+ [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] &&
continue
sofar="$sofar $file"
sofar=" $(eval _muttconffiles \"$sofar\" $file) "
Helmut
That change was committed in order to fix http://alioth.debian.org/tracker/index.php?func=detail&aid=312881&group_id=100114&atid=413095 Can you suggest another way to fix that issue that would keep mutt aliases working? I'm not a mutt user nor do I know much at all about it so testing suggested changes (if any) is appreciated.
I don't really understand what's going on on the bash side here. Some experiments revealed that it actually boils down to the "-f". So my aliases file is included as: source ~/.mutt/aliases Assuming that the right part goes to $file I can see that test -f fails even though the file is present: $ test -f "~/.mutt/aliases"; echo $? 1 $ This in turn is due to the fact that the ~ is not expanded. Not quoting $file would solve this but it would probably lead to other problems. (On the other hand it is used unquoted a few lines later.) Well at least you have a test case now. :-) Helmut
I played with a test case outside of the mutt completion and think removing the quoting would not actually help. But adding a __expand_tilde_by_ref call probably would; could you test this?--- a/completions/mutt +++ b/completions/mutt @@ -63,2 +63,3 @@ _muttconffiles() for file in "${newconffiles[@]}"; do + __expand_tilde_by_ref file [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] &&
You are correct here. source ~/somefile while it still does not expand source "~/somefile" which is read by mutt as well. Looks like we have a new test case. ;-) Helmut PS: Yes, I could simply remove the quotes, but this regression will probably hit others as well, so let's pursue it.
We'll probably need an eval somewhere. Does removing the quotes actually fix this for you? And if yes, exactly which quotes?
Sorry for the delay, I somehow didn't see the message earlier. ... I think my previous mail explains this nicely. I added the proposed __expand_tilde_by_ref to my /etc/bash_completion.d/mutt. After doing so a line in my .muttrc source ~/somefile is properly processed by bash_completion whereas a line source "~/somefile" is not. Do you see which quotes I am referring to? Helmut
Yes - just to make sure, you removed the quotes from the mentioned line
in your .muttrc. I can see how that makes things work.
But in one of your earlier comments (message 15) you mentioned "Not
quoting $file would solve this ...", to which I replied (message 20)
that I couldn't see why doing that would help (and still can't), then
you mentioned "I could simply remove the quotes" (message 25) at which
point it was no longer clear to me which exactly which quotes are being
discussed - around $file in the mutt completion or something in your muttrc.
If you have a patch to the mutt completion that makes lines like 'source
"~/somefile"' work in addition to 'source ~/somefile' (preferably
against current bash-completion git), I'd be interested in taking a
look. As said earlier, I suppose we'll need an eval somewhere to make
that work; maybe something like this (100% untested):
diff --git a/completions/mutt b/completions/mutt
index c5d5d1f..372be3c 100644
--- a/completions/mutt
+++ b/completions/mutt
@@ -63,3 +63,3 @@ _muttconffiles()
for file in "${newconffiles[@]}"; do
- __expand_tilde_by_ref file
+ eval file="$file"
[[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] &&
Well I simply reverted the offending hunk (not understanding why it breaks my setup). That would be this one:--- a/bash_completion.d/mutt +++ b/bash_completion.d/mutt @@ -61,7 +61,7 @@ _muttconffiles() while [[ "$1" ]]; do newconffiles=( $(sed -n 's|^source[[:space:]]\{1,\}\([^[:space:]]\{1,\}\).*$|\1|p' $(eval echo $1) ) ) for file in "${newconffiles[@]}"; do - [[ ! "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && + [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && continue sofar="$sofar $file" sofar=" $(eval _muttconffiles \"$sofar\" $file) " This works fine for me, but it would cause another bug to reappear for other users. In any case you do have a reproducible test case now, so you should be able to test your proposed solutions by yourself instead of throwing random untested hunks at me. Helmut
No worries, I'll stop trying to help with this issue right now. I'm not a mutt nor a Debian user, perhaps there's someone else who is at least one of those interested in looking into this further.
Well this is technically a regression. A regression has an obvious solution: revert. If there is is no better solution, then revert is the solution. In any case your proposed hunk does not improve the situation. It was:--- a/completions/mutt +++ b/completions/mutt @@ -63,3 +63,3 @@ _muttconffiles() for file in "${newconffiles[@]}"; do - __expand_tilde_by_ref file + eval file="$file" [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && The idea with eval however was good. So how about this (tested) hunk?--- a/completions/mutt +++ b/completions/mutt @@ -63,3 +63,3 @@ _muttconffiles() for file in "${newconffiles[@]}"; do + file="$(eval echo $file)" __expand_tilde_by_ref file [[ ! -f "$file" || "${sofar/ ${file} / }" != "$sofar" ]] && In the beginning of the for loop $file is a quoted string, the eval removes the quotes and the __expand_tilde_by_ref expands the tilde (since $file is no longer quoted). On the down side I suspect that this would introduce new problems with filenames containing spaces, backslashes or dollar signs. Additionally I always have a bad feeling evaluating random strings from random files. What are the security implications? Helmut
We believe that the bug you reported is fixed in the latest version of
bash-completion, which is due to be installed in the Debian FTP archive:
bash-completion_1.90-1.debian.tar.gz
to main/b/bash-completion/bash-completion_1.90-1.debian.tar.gz
bash-completion_1.90-1.dsc
to main/b/bash-completion/bash-completion_1.90-1.dsc
bash-completion_1.90-1_all.deb
to main/b/bash-completion/bash-completion_1.90-1_all.deb
bash-completion_1.90.orig.tar.bz2
to main/b/bash-completion/bash-completion_1.90.orig.tar.bz2
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 615134@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
David Paleino <dapal@debian.org> (supplier of updated bash-completion package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@debian.org)
Format: 1.8
Date: Thu, 03 Nov 2011 13:03:51 +0100
Source: bash-completion
Binary: bash-completion
Architecture: source all
Version: 1:1.90-1
Distribution: experimental
Urgency: low
Maintainer: Bash Completion Maintainers <bash-completion-devel@lists.alioth.debian.org>
Changed-By: David Paleino <dapal@debian.org>
Description:
bash-completion - programmable completion for the bash shell
Closes: 577933 593835 604393 615134 618734 619014 622383 623680 625234 642526
Changes:
bash-completion (1:1.90-1) experimental; urgency=low
.
* bash-completion 2 preview: dynamic loading of completions
- optionally fallback to generic file completion if _filedir
returns nothing (Closes: #619014, LP: #533985)
- various fixes (Closes: #622383)
- apt: add 'download' to subcommands (Closes: #625234, LP: #720541)
- aptitude: add 'versions' command (Closes: #604393)
- dpkg-query: use the 'dpkg' completion (Closes: #642526)
- lintian: remove --unpack-level (Closes: #623680)
- rrdtool: complete filenames after commands (Closes: #577933)
- provide profile.d hook for per user disabling of bash_completion
(Closes: #593835)
- mutt: support tildes when recursively sourcing muttrc files
(Closes: #615134)
- tar: improve tar *[cr]*f completions (Closes: #618734)
* More checks in update-bash-completion: avoid unnecessary
sourcing of completion if symlink already exists
* Add message for users before they report a bug (debian/bug-presubj),
I'm kind of fed-up with bugs caused by acroread.sh :/
* Removed patches merged upstream
* Drop trigger-based completion loading
* Standards-Version bump to 3.9.2, no changes needed
Checksums-Sha1:
748b796aa5f70f17b2c3ec449dd7a8d66933bb8a 1394 bash-completion_1.90-1.dsc
aa1a1f4e34bff93f8227c1a200de310a04a21e86 228640 bash-completion_1.90.orig.tar.bz2
e5deb79d3aa91dff60baee0d4f1675fc5fd6ea2b 13057 bash-completion_1.90-1.debian.tar.gz
64a6a900971b2bc4d6d8706345f3037c81b85762 179058 bash-completion_1.90-1_all.deb
Checksums-Sha256:
78c827e512975c885b3cb09a2a50676d2f8bcd3c81b712a18035b288bfa0d92a 1394 bash-completion_1.90-1.dsc
293084b7584e89734002a49688ca9aea2bab16ca4750b30f66b62a373750c41c 228640 bash-completion_1.90.orig.tar.bz2
06975fe1a3291aadad7489d381183bcc64731f6b256647b8a5e277bb16ae97a8 13057 bash-completion_1.90-1.debian.tar.gz
4f78b12ab95b5ed24c8fe63e26d9f1635f189ccb9c7f7b503af101c0dfe92fe0 179058 bash-completion_1.90-1_all.deb
Files:
adf23b480b86c55d9e337258164785a0 1394 shells standard bash-completion_1.90-1.dsc
82635839d83074eba923822fd584490c 228640 shells standard bash-completion_1.90.orig.tar.bz2
ab9637c3c2aea423af97932b19bdc832 13057 shells standard bash-completion_1.90-1.debian.tar.gz
e43e91227a8d739a095577d51a1e0b78 179058 shells standard bash-completion_1.90-1_all.deb
iEYEARECAAYFAk6yhD8ACgkQ5qqQFxOSsXQUSACfdui594rcT9CfiI3CyWfl60xa
UpMAoKbynog3IF+e2EOHcrFL6VBNbHPO
=Wi2f
-----END PGP SIGNATURE-----
Hi, Helmut Grohne, I noticed that you reopened this bug report and I suppose you did so because you think that the bug is only partially fixed (as suggested in message #25 [1]). I just submitted a patch upstream [2] that, to the best of my knowledge, fixes the rest of the problem, but since I'm not a mutt user, could you please confirm that it also works for you? [1] https://bugs.debian.org/615134#25 [2] https://github.com/scop/bash-completion/pull/261
Uff, this is an old bug. I confirm that it is partially fixed in the version in Debian unstable. A source line with quotes and tilde is not followed, but without quotes a tilde is correctly expanded. In my local configuration, I've removed the quotes and was happy since. I confirm that the patch makes mutt source stanzas with quotes and tilde work. The commit description precisely describes the problem. Thank you. Helmut