Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 ?

share|improve this question

1 Answer 1

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

 
discard

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.