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

Re: scp and globbing in zsh



On Fri, 23 Jul 2004, matt m wrote:

> $ scp someserver:~/tmp/*.txt  .
> $ scp *.txt  someserver:~/tmp/
> 
> I could just put single quotes around the server path to get it to work 
> with globbing but after many years of bash I am having trouble getting 
> into the habbit of using single quotes with scp

I suspect that you just want "setopt no_nomatch" so that the glob pattern 
is left unexpanded when it doesn't find any matching files.  (You may have 
to "unsetopt null_glob csh_null_glob" as well.)  That's the only way I can
think of that this would do as you seem to expect in bash but not in zsh.

If for some reason you want "nomatch" behavior for other commands but not
for scp, you have to play some games of this sort:

  glob_scp() {
    emulate -L zsh
    array args
    local a
    for a
    do
      if [[ $a = *:* ]]
      then
        args=( $args $a )	# args+=($a) if you have zsh 4.2+
      else
        args=( $args $~a )	# args+=($~a)
      fi
    done
    scp $args
  }
  alias scp='noglob glob_scp'



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