zsh-users
 help / color / mirror / code / Atom feed
* scp and globbing in zsh
@ 2004-07-23 16:48 matt m
  2004-07-23 17:05 ` Peter Stephenson
  2004-07-23 17:47 ` Bart Schaefer
  0 siblings, 2 replies; 7+ messages in thread
From: matt m @ 2004-07-23 16:48 UTC (permalink / raw)
  To: zsh-users

I migrated from bash to zsh about a month ago (loving it) and there is
still one thing I cannot figure out. I would like to be able to use
regex (at least the *) with scp. For example:

$ scp someserver:~/tmp/*.txt  .
$ scp *.txt  someserver:~/tmp/

The first one fails with globbing because it seems to be looking for
~/tmp/*.txt on my local machine instead of the remote machine but the
second command works fine. With no globbing set for scp the first
command works but the second command fails.

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 and it get's
pretty frustrating.

Is there a way to get this to work so that both of the above commands
work as expected without having to use single quotes? Thanks for any
input.
-- 
allucid
allucid@gmail.com


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

* Re: scp and globbing in zsh
  2004-07-23 16:48 scp and globbing in zsh matt m
@ 2004-07-23 17:05 ` Peter Stephenson
  2004-07-23 17:23   ` matt m
  2004-07-23 17:37   ` Wayne Davison
  2004-07-23 17:47 ` Bart Schaefer
  1 sibling, 2 replies; 7+ messages in thread
From: Peter Stephenson @ 2004-07-23 17:05 UTC (permalink / raw)
  To: zsh-users

matt m wrote:
> $ scp someserver:~/tmp/*.txt  .
> $ scp *.txt  someserver:~/tmp/
> 
> The first one fails with globbing because it seems to be looking for
> ~/tmp/*.txt on my local machine instead of the remote machine but the
> second command works fine.

Zsh is set by default to report an error when any pattern match fails.
You probably want to pass through any unrecognised patterns to the
command.  You can do that with:

setopt nonomatch

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: scp and globbing in zsh
  2004-07-23 17:05 ` Peter Stephenson
@ 2004-07-23 17:23   ` matt m
  2004-07-23 17:37   ` Wayne Davison
  1 sibling, 0 replies; 7+ messages in thread
From: matt m @ 2004-07-23 17:23 UTC (permalink / raw)
  To: zsh-users

On Fri, 23 Jul 2004 18:05:06 +0100, Peter Stephenson <pws@csr.com> wrote:
> matt m wrote:
> > $ scp someserver:~/tmp/*.txt  .
> > $ scp *.txt  someserver:~/tmp/
> >
> > The first one fails with globbing because it seems to be looking for
> > ~/tmp/*.txt on my local machine instead of the remote machine but the
> > second command works fine.
> 
> Zsh is set by default to report an error when any pattern match fails.
> You probably want to pass through any unrecognised patterns to the
> command.  You can do that with:
> 
> setopt nonomatch

That's just what I was looking for, thank you. 
-- 
allucid
allucid@gmail.com


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

* Re: scp and globbing in zsh
  2004-07-23 17:05 ` Peter Stephenson
  2004-07-23 17:23   ` matt m
@ 2004-07-23 17:37   ` Wayne Davison
  1 sibling, 0 replies; 7+ messages in thread
From: Wayne Davison @ 2004-07-23 17:37 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-users

On Fri, Jul 23, 2004 at 06:05:06PM +0100, Peter Stephenson wrote:
> Zsh is set by default to report an error when any pattern match fails.
> You probably want to pass through any unrecognised patterns to the
> command.  You can do that with:
> 
> setopt nonomatch

That does have the consequence of not telling you when you actually
mistype a local match pattern.  I prefer to leave nomatch set and to
manually quote wildcards that need to be expanded remotely.  You'd
either use quotes or a backslash, like this:

$ scp someserver:tmp/\*.txt .

(Note that the leading "~/" isn't needed since ssh defaults to being in
your home directory.)  Just my 2 cents.

..wayne..


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

* Re: scp and globbing in zsh
  2004-07-23 16:48 scp and globbing in zsh matt m
  2004-07-23 17:05 ` Peter Stephenson
@ 2004-07-23 17:47 ` Bart Schaefer
  2004-07-23 20:24   ` Vincent Lefevre
  1 sibling, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2004-07-23 17:47 UTC (permalink / raw)
  To: zsh-users

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'


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

* Re: scp and globbing in zsh
  2004-07-23 17:47 ` Bart Schaefer
@ 2004-07-23 20:24   ` Vincent Lefevre
  2004-07-24 18:35     ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Vincent Lefevre @ 2004-07-23 20:24 UTC (permalink / raw)
  To: zsh-users

On 2004-07-23 10:47:20 -0700, Bart Schaefer wrote:
>   glob_scp() {
>     emulate -L zsh
>     array args
      ^^^^^^^^^^

Shouldn't this be "local -a args" ?

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/>
100% validated (X)HTML - Acorn / RISC OS / ARM, free software, YP17,
Championnat International des Jeux Mathématiques et Logiques, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: scp and globbing in zsh
  2004-07-23 20:24   ` Vincent Lefevre
@ 2004-07-24 18:35     ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2004-07-24 18:35 UTC (permalink / raw)
  To: zsh-users

On Fri, 23 Jul 2004, Vincent Lefevre wrote:

> On 2004-07-23 10:47:20 -0700, Bart Schaefer wrote:
> >   glob_scp() {
> >     emulate -L zsh
> >     array args
>       ^^^^^^^^^^
> 
> Shouldn't this be "local -a args" ?

Yes, it should, sorry.


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

end of thread, other threads:[~2004-07-24 18:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-07-23 16:48 scp and globbing in zsh matt m
2004-07-23 17:05 ` Peter Stephenson
2004-07-23 17:23   ` matt m
2004-07-23 17:37   ` Wayne Davison
2004-07-23 17:47 ` Bart Schaefer
2004-07-23 20:24   ` Vincent Lefevre
2004-07-24 18:35     ` Bart Schaefer

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).