zsh-workers
 help / color / mirror / code / Atom feed
From: Philippe Troin <phil@fifi.org>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: A cute bug involving aliases and _remote_files
Date: Wed, 27 Feb 2019 00:27:30 -0800	[thread overview]
Message-ID: <20c973717ab6749fef5694b76a9f7b72a35ee72c.camel@fifi.org> (raw)
In-Reply-To: <3D38E0FC-DE43-4CFD-86E2-B258D9DA816C@dana.is>

On Tue, 2019-02-26 at 03:23 -0600, dana wrote:
> On 25 Feb 2019, at 20:49, Philippe Troin <phil@fifi.org> wrote:
> > Would it make sense to use "command ls" instead of "ls" for remote
> > directory listings in _remote_files?  That would make sure that no
> > aliases nor functions are involved.
> 
> That *seems* reasonable...?
> 
> Now that you mention it, GNU ls changed its default quoting behaviour somewhat
> recently. I think it only quotes when (a) QUOTING_STYLE is set, (b)
> one of the
> quoting options is given on the command line, or (c) the output is a
> TTY — so
> it's unlikely to be an issue for _remote_files, given how it's
> normally used.
> But maybe it'd be a good idea to force it off anyway, just in case?

I'm completely unaware of how QUOTING_STYLE could possibly be getting
us into trouble, but the way you call the binary (variable=value
command ls) is bourne-shell only (bash, sh, ash, ksh), and will not
work if the remote system is using c-shells (csh, tcsh).
I'd recommend using env, as in:

+  remfiles=(${(M)${(f)"$(
+    _call_program files $cmd $cmd_args $host \
+      env QUOTING_STYLE=literal ls -d1FL -- "$rempat" > 2>/dev/null
+  )"}%%[^/]#(|/)})

That will work everywhere.
Now, I haven't seen anyone using c-shells in a very long while, but I'm
sure there are some holdouts :-)

Since you use "env" instead of calling ls directory, you don't need
command anymore, because no alias expansion will occur for ls.
I assume we don't care about global aliases, which none of the proposed
solutions would handle anyways.

Phil.

> diff --git a/Completion/Unix/Type/_remote_files
> b/Completion/Unix/Type/_remote_files
> index 267715a51..89cf102cf 100644
> --- a/Completion/Unix/Type/_remote_files
> +++ b/Completion/Unix/Type/_remote_files
> @@ -59,7 +59,10 @@ if zstyle -T ":completion:${curcontext}:files"
> remote-access; then
>    fi
>  
>    # remote filenames
> -  remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args $host ls
> -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)})
> +  remfiles=(${(M)${(f)"$(
> +    _call_program files $cmd $cmd_args $host \
> +      QUOTING_STYLE=literal command ls -d1FL -- "$rempat"
> 2>/dev/null
> +  )"}%%[^/]#(|/)})
>  
>    compset -P '*/'
>    compset -S '/*' || (( ${args[(I)-/]} )) || suf='remote file'
> 


  parent reply	other threads:[~2019-02-27  8:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-26  2:49 Philippe Troin
2019-02-26  9:23 ` dana
2019-02-26  9:40   ` Peter Stephenson
2019-02-27  8:27   ` Philippe Troin [this message]
2019-02-27  8:42     ` dana

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20c973717ab6749fef5694b76a9f7b72a35ee72c.camel@fifi.org \
    --to=phil@fifi.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).