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

A cute bug involving aliases and _remote_files



Hi,

I have the following aliases in my .zshenv:
  alias ls='command ls -Fbv'

The interesting part there is the "-b" which instructs ls to quote
unprintable characters and spaces.

But in _remote_files we do:
  _call_program files $cmd $cmd_args $host ls -d1FL -- 
which will use the alias, and when I complete a file with a space, zsh
ends up prefixing the space with 7 backslashes, as there's now an extra
round of escaping performed.

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.
I don't need any downsides as all shells that I'm aware of have the
"command" pre-command modifier.

Example of the issue (you need to alias ls as described above for this
to show):

% mkdir test_dir
% touch test_dir/'a file'
% scp localhost:$PWD/test_dir/a
                               ^ Press TAB
===> completes to:
% scp localhost:$PWD/test_dir/a\\\\\\\ file

I have this in my .zshrc in the meantime:
     _remote_files() {
       unfunction _remote_files
       autoload +X _remote_files
       if [[ $functions[_remote_files] != *' command ls -' ]]
       then
         functions[_remote_files]=${functions[_remote_files]// ls -/ command ls -}
       fi
       _remote_files $*
     }


Yet it would be neat if this were fixed upstream.
Thanks,

Phil.



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