Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _mpc breaks when folder contains spaces



Oliver Schmidhauser wrote:
>
> I have a problem with mpc and the completion function.

> mpc add Electronic/Laserkraft\ 3D/mpd error: No such directory

> I've attached a .patch for _mpc which fixes this issue, as in it
> replaced `\ ` with ` ` before it is being passed to `mpc tab`. This
> probably doesn't fix the root of the issue, why `$word[CURRENT]`
> contains "Electronic/Laserkraft\ 3D" instead of "Electronic/Laserkraft
> 3D". It probably also breaks when a folder actually contains `\ `.

It looks like you forgot to include the attachment. Does it resemble the
following patch? I believe it is the correct fix.

> The second issue I have is `mpc tab` outputing errors while I am
> trying to autocomplete, breaking the current prompt so that I have to
> `Ctrl+C` and restart.

I'll take a look at that and post a patch to -workers later. The mpc
function should be using _call_program in the many places when calling
out to mpc. That takes care of redirecting stderr among other things.

Oliver

diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index e0c6888b0..d4073c3cd 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -147,7 +147,7 @@ _mpc_helper_files() {
     list=( ${${(f)"$(mpc listall)"}%%/*})
     _wanted files expl file compadd -qS/ -a list
   else
-    list=(${(f)"$(mpc tab $words[CURRENT])"})
+    list=(${(f)"$(mpc tab ${(Q)words[CURRENT]})"})
     _wanted files expl file _multi_parts / list
   fi
 }



Messages sorted by: Reverse Date, Date, Thread, Author