0

This works from command line:

scp -r ^.git b:/home/wopi/blyzics/.

when I paste the above line in a script like this:

#!/usr/bin/env zsh
scp -r ^.git b:/home/wopi/blyzics/.

And run it

./deploy.sh

I get:

^.git: No such file or directory

Why ?

astropanic
  • 307
  • 2
  • 5
  • 18

1 Answers1

1

Using ^.filename is a feature enabled only when EXTENDED_GLOB is set. You probably have this set in your .zshrc for interactive use, but a shell script won't be using this.

See the zsh manual for info. To enable this in your scripts you can simply run:

setopt extended_glob

at the top of your script. Note that this isn't portable, however.

James O'Gorman
  • 5,329
  • 2
  • 24
  • 28
  • No way for a shell script to use this option ? I mean without pasting the setopt extendglob in each schell script ? (I have this option set in my shell) – astropanic Jan 28 '13 at 12:58
  • For compatibility reasons most of these options aren't on by default, so if you want to use zsh for scripting you need to tell it to turn on zsh-specific options. There's nothing wrong with using `setopt` in a script. – James O'Gorman Jan 28 '13 at 17:58