Reputation: 2453
I am trying to use brace expansion in a bash script as follows.
#!/bin/bash
document_root="/var/www/www.example.com"
`chmod -R g+w $document_root/{../captcha,../files}`
this gives me the error
chmod: cannot access `/var/www/www.example.com/{../captcha,../files}': No such file or directory
but when I run this in a terminal it works just fine.
Upvotes: 2
Views: 2310
Reputation: 5061
Stumbled over this issue myself. In my case I was using set -eu
command at some point of my script resulting in this particular issue. Fix was to add -B
option like set -euB
re-enabling brace expansion for it has been disabled for some reason though manual states it is enabled by default.
Upvotes: 1
Reputation: 36
Have you tried this way?
#!/bin/bash
document_root="/var/www/www.example.com"
chmod -R g+w $document_root/{"../captcha","../files"}
Upvotes: 1
Reputation: 140227
#!/bin/bash
document_root="/var/www/www.example.com"
chmod -R g+w $document_root/{../captcha,../files}
$
when you are assigning to a variable, only when expandingUpvotes: 4