zsh-users
 help / color / mirror / code / Atom feed
* _mpc breaks when folder contains spaces
@ 2017-08-22 11:12 Oliver Schmidhauser
  2017-08-22 15:57 ` Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Schmidhauser @ 2017-08-22 11:12 UTC (permalink / raw)
  To: zsh-users

Hi all!

I have a problem with mpc and the completion function.

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

It seems to have a problem with the `\ ` in the path. It seems to be passed along to `mpc tab`, which it probably shouldn't.
I made a short video which demonstrates this problem: https://asciinema.org/a/vkNebrU6v5b9XYrMrdVeKpfB8

I've already raised this issue with mpc here: https://github.com/MusicPlayerDaemon/mpc/issues/7. The Maintainer of mpc made it very clear that the fault doesn't lie with mpc, but with zsh.

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 `\ `.

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've tested this with the minimal default config that generates when you run `zsh-newuser-install` and enable completion. I am running mpc 0.28 and zsh 5.4.1.

Thanks for any help,
glow


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: _mpc breaks when folder contains spaces
  2017-08-22 11:12 _mpc breaks when folder contains spaces Oliver Schmidhauser
@ 2017-08-22 15:57 ` Oliver Kiddle
  2017-08-22 17:49   ` Oliver Schmidhauser
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2017-08-22 15:57 UTC (permalink / raw)
  To: Oliver Schmidhauser; +Cc: zsh-users

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
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: _mpc breaks when folder contains spaces
  2017-08-22 15:57 ` Oliver Kiddle
@ 2017-08-22 17:49   ` Oliver Schmidhauser
  0 siblings, 0 replies; 3+ messages in thread
From: Oliver Schmidhauser @ 2017-08-22 17:49 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: zsh-users

On Tue, Aug 22, 2017 at 05:57:57PM +0200, Oliver Kiddle wrote:
> It looks like you forgot to include the attachment.
Yeah, I seem to have forgot to attach it. Here it is. But yours is probably way better. Thanks for looking into this.

--- _mpc.old	2017-08-22 11:31:01.336095638 +0200
+++ _mpc	2017-08-22 11:31:07.226095636 +0200
@@ -147,7 +147,7 @@
     list=( ${${(f)"$(mpc listall)"}%%/*})
     _wanted files expl file compadd -qS/ -a list
   else
-    list=(${(f)"$(mpc tab $words[CURRENT])"})
+    list=(${(f)"$(mpc tab ${words[CURRENT]//\ / })"})
     _wanted files expl file _multi_parts / list
   fi
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-22 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-22 11:12 _mpc breaks when folder contains spaces Oliver Schmidhauser
2017-08-22 15:57 ` Oliver Kiddle
2017-08-22 17:49   ` Oliver Schmidhauser

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).