Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


I get:

^.git: No such file or directory

Why ?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.