I'm writing a script to copy some files around, and trying to use shopt -s dotglob
to enable cp to copy dotfiles like .jshint
and whatnot.
I can run shopt -s dotglob
directly at a bash prompt with no error. However, running the script throws the error:
script.sh: 81: script.sh: shopt: not found
I'm running this script in bash shell, with the shebang header #!/usr/bin/env bash
. Error line:
shopt -s dotglob
cp -r $TEMP/img/* $TARGET/img/
cp -r $TEMP/js/* $TARGET/js/
cp -r $TEMP/less/* $TARGET/less/
Not finding anything helpful on google, any idea what the problem is here?
#!/bin/bash
header?shopt
is a bash builtin,sh
does not haveshopt
, and the error message looks like an error message fromdash
. So most likely the error here is running a bash script withsh
(which in Ubuntu isdash
by default). Even ifsh
is a symlink tobash
, running a bash script withsh
is not the same as running it withbash
.