[Bug 474361] New: bash competion fail to complete names with spaces
https://bugzilla.novell.com/show_bug.cgi?id=474361 Summary: bash competion fail to complete names with spaces Classification: openSUSE Product: openSUSE 11.1 Version: Final Platform: All OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: Basesystem AssignedTo: bnc-team-screening@forge.provo.novell.com ReportedBy: jreidinger@novell.com QAContact: qa@suse.de CC: jkupec@novell.com Found By: Development Created an attachment (id=271582) --> (https://bugzilla.novell.com/attachment.cgi?id=271582) new bash completion for zypper I attach completion script for zypper. this script have problems with repositories which contain spaces. e.g. I have repository "openSUSE 11.1" and this bash completion: zofie:/home/jreidinger # zypper modifyrepo 11.1-0 --name repo-debug --all nofac repo-non-oss --disable --no-keep-packages repo-oss --enable --no-refresh Repository fate openSUSE\ repo-source --keep-packages Packman\ repo-update --local --priority trans --medium-type --refresh xfce moje --remote zofie:/home/jreidinger # zypper modifyrepo o 11.1-0 openSUSE\ zofie:/home/jreidinger # zypper modifyrepo openSUSE\ 1 11.1-0 openSUSE\ zofie:/home/jreidinger # zypper modifyrepo openSu (no help) zofie:/home/jreidinger # zypper modifyrepo openSUSE\ 12 11.1-0 openSUSE\ So problem is in incostistency showed help and also that because this is last option it should autocomplete it. I fill it as 'openSUSE\ 11.1-0' so I think partially it must be accepted. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 Pavol Rusnak <prusnak@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|bnc-team-screening@forge.pr |werner@novell.com |ovo.novell.com | -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c1 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |prusnak@novell.com, | |werner@novell.com AssignedTo|werner@novell.com |jkupec@novell.com --- Comment #1 from Dr. Werner Fink <werner@novell.com> 2009-02-18 07:35:30 MST --- Tip: remove the package bash-completion. It's broken. Beside this the /etc/bash_completion.d/zypper.sh is broken. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c2 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|jkupec@novell.com |werner@novell.com --- Comment #2 from Ján Kupec <jkupec@novell.com> 2009-02-18 08:17:47 MST --- I guess this is a report against 'compgen' or the mechanism that feeds COMP_WORDS, so why did you reassign it to me? (In reply to comment #1)
Tip: remove the package bash-completion. It's broken.
AFAIK, this has nothing to do with bash-completion package.
Beside this the /etc/bash_completion.d/zypper.sh is broken.
The old one is, but Josef is trying to make it work (see the attached script), and he has a problem with completing strings which contain whitespace. He wants to complete them with whitespace already escaped, so that the user just hits enter after the value is completed. I guess he uses something like: compgen -W "'asdf\ long' 'asfd' ..." ... and this fails (see c#0). Can you help with this? Is this a bug (compgen, bash)? Or if you're not the one to handle this, do you have an idea who is? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c3 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|werner@novell.com |jkupec@novell.com --- Comment #3 from Dr. Werner Fink <werner@novell.com> 2009-02-18 08:33:54 MST --- The problem of bug #470548 is already fixed. It is the script /etc/bash_completion.d/zypper.sh which is broken ... if you're using a word list for compgen you may temporary change the IFS variable otherwise the script may fail. From man bash -W wordlist The wordlist is split using the characters in the IF special variable as delimiters, and each resultant word is expanded. The possible completions are the members of the resultant list which match the word being completed. by default IFS is <space><tab><newline> ... for an example how to use IFS see /etc/profile.d/complete.bash . -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c4 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO CC| |jsrain@novell.com Info Provider| |jreidinger@novell.com AssignedTo|jkupec@novell.com |werner@novell.com --- Comment #4 from Ján Kupec <jkupec@novell.com> 2009-02-18 09:10:24 MST --- Seems like this could work, Pepo, can you try? But still, look at this: $ IFS='#' compgen -W "asdf\\\ long#asfd" 'asdf\ ' $ IFS='#' compgen -W "asdf\\\ long#asfd" 'asdf\\ ' asdf\ long I'd say the first line should work, rather than the second. Werner: please don't reassign back to me, i'm telling you this has nothing to do with the old zypper.sh script that you see in /etc/bash_completion.d/zypper.sh. This is between you and Josef, see if this is a bug and either close it as invalid, or wontfix or fixed, don't reassign. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c5 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|werner@novell.com |jreidinger@novell.com --- Comment #5 from Dr. Werner Fink <werner@novell.com> 2009-02-18 09:24:28 MST --- I'm not the author nor maintainer of /etc/bash_completion.d/zypper.sh nor maintainer of the package zypper and /etc/bash_completion.d/zypper.sh is part of zypper ... isn't it? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c6 --- Comment #6 from Dr. Werner Fink <werner@novell.com> 2009-02-18 09:28:53 MST --- Btw: simply asking me instead of dropping a bugzilla into my bug list would be perfect ;) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jreidinger@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c7 Josef Reidinger <jreidinger@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Info Provider|jreidinger@novell.com |werner@novell.com --- Comment #7 from Josef Reidinger <jreidinger@novell.com> 2009-02-19 00:23:27 MST --- Hi, thanks for your comment. At first I want say, that change IFS doesn't help as long as all characters is possible in repo names. What I find broken is not compgen, which I think generate correctly if I use in word list escaped IFS character. compgen -W "test lest" test lest compgen -W "test\ lest" test lest What I find problematic is that when I assign escaped value to COMPREPLY then it appear in behavior which I describe in initial commend (bash hint correct allias, but cannot complete it to full version. You can see actual development version of zypper bash complete here - http://git.opensuse.org/?p=projects/zypp/zypper.git;a=blob;f=src/bash-comple... Could you please specify what is break? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c10 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|jreidinger@novell.com |werner@novell.com --- Comment #10 from Dr. Werner Fink <werner@novell.com> 2009-02-19 06:37:28 MST --- Created an attachment (id=273933) --> (https://bugzilla.novell.com/attachment.cgi?id=273933) zypper.sh A rewrite which should now work with empty spaces. Beside this I've reduced the string filters to use sed only, also I'm using shell arrays without overwriting it with a string, and at last but not least I use number variables. Please test out. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW Info Provider|werner@novell.com | -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c11 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|werner@novell.com |jreidinger@novell.com --- Comment #11 from Dr. Werner Fink <werner@novell.com> 2009-02-19 07:09:30 MST --- Please, this is not my bug ... stop assigning me this bug. The original shell from attachment #271582 script was never written by me nor I've done any change to this script. As I've demonstrated with the modified script (see attchment #273933) correct shell syntax does its work. This new script resprects the IFS variable and results in e.g.: /suse/werner> bash werner@boole:~> . zypper.sh werner@boole:~> zypper modifyrepo --all --no-keep-packages openSUSE-11.1-Updates --disable --no-refresh repo-debug --enable --priority repo-non-oss --keep-packages --refresh repo-oss --local --remote repo-source --medium-type full-11.1-i586 repo-update --name openSUSE 11.1-0 werner@boole:~> zypper modifyrepo q.e.d. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c12 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #273933|0 |1 is obsolete| | --- Comment #12 from Dr. Werner Fink <werner@novell.com> 2009-02-19 08:15:59 MST --- Created an attachment (id=273967) --> (https://bugzilla.novell.com/attachment.cgi?id=273967) zypper.sh A more rugged version ... now it escapes the spaces found in names and also removes unwanted spaces which may cause negative array subscript otherwise. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c13 Dr. Werner Fink <werner@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |NEEDINFO Info Provider| |jkupec@novell.com --- Comment #13 from Dr. Werner Fink <werner@novell.com> 2009-02-19 08:20:44 MST --- Is this what you've requested? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c14 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |NEW Info Provider|jkupec@novell.com | --- Comment #14 from Ján Kupec <jkupec@novell.com> 2009-02-19 09:00:14 MST --- c#12 - Exactly! It works, thanx a lot! :O) (In reply to comment #11)
Please, this is not my bug ... stop assigning me this bug.
You reassigned it to yourself the last time :O) Check the history
The original shell from attachment #271582 [details] script was never written by me nor I've done any change to this script.
Nobody ever said that. All that was said is that there could have been a bug in bash. But you showed us a way out of it, so thanx again. So the problem was the use of the default IFS we one expects those white characters in the to-be-completed strings? BTW, i guess the right way to handle this report should be to leave it assigned to you and resolve as INVALID, but i won't argue with you anymore :O) -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c15 --- Comment #15 from Ján Kupec <jkupec@novell.com> 2009-02-19 09:01:34 MST --- (In reply to comment #14)
So the problem was the use of the default IFS we one expects those white ^^ when
-- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User werner@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c16 --- Comment #16 from Dr. Werner Fink <werner@novell.com> 2009-02-19 09:13:58 MST ---
All that was said is that there could have been a bug in bash. But you showed us a way out of it, so thanx again.
There is no bug in bash completion ... beside that is is not very handy like completion in tcsh or zsh. As you can see from script in attachment #273967 it requires wide bash knowledge to write such scripts ... a reason why some of the hasty written completion functions of the bash_completion package will fail in some corner cases. And the reason why simple completions for the cd command leads into such large shell function as found in /etc/profile.d/complete.bash ... you may compare this with /etc/profile.d/complete.tcsh ... last one is (IMHO) much more reliable. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jreidinger@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c17 Josef Reidinger <jreidinger@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P5 - None |P3 - Medium AssignedTo|jreidinger@novell.com |jkupec@novell.com Severity|Normal |Minor --- Comment #17 from Josef Reidinger <jreidinger@novell.com> 2009-02-24 10:18:13 MST --- jano - I find this script working and clearly written, so please commit it to zypper repository, as I doesn't have push rights to current git repo. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=474361 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=474361#c18 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #18 from Ján Kupec <jkupec@novell.com> 2009-03-02 05:32:13 MST --- Done. Will push it soon. Thank you guys! commit 7cbd4def398ffb38732e0d935a2539e9fbe93ff6 Author: Werner Fink <werner@suse.de> Date: Mon Mar 2 13:26:41 2009 +0100 bash-completion: Allow empty spaces in repos names. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com