I'm running git-bash on windows. I feel the issue I'm facing is more of a NIX geared question than windows. I have a shell script:
build.sh
myProject="../myProject/"
build="gulp build"
cd "${myProject}"
pwd
"${build}"
When I run this script I get error
gulp build: command not found
When I run "gulp build" directly in the shell, running these same commands by hand then everything works. I tried executing the script via:
. build.sh
and just build.sh
Same error either way. How can I run a script that can access gulp/npm? Why does this fail even when I am sourcing the script?
Best Answer
Quoting
"${build}"
prevents word splitting, so it has the same effect here as writing"gulp build"
(with quotes), which would search for an executable calledgulp build
with a space inside the name; and not as writinggulp build
, which executesgulp
with abuild
argument.Concluding, the last line of your script should be: