I have a Bash script that performs a simple substitution on OS X. Here's the reduced case:
mkdir vs2005-dynamic
cp cryptdll.vcproj cryptest.sln cryptest.vcproj cryptlib.vcproj dlltest.vcproj vs2005-dynamic/
cd vs2005-dynamic
...
SED=/opt/local/bin/gsed
SEDOPTS=(-i "")
...
PROJ_FILES=($(find $PWD -name "*.vcproj"))
for pf in "${PROJ_FILES[@]}"; do
"$SED" "${SEDOPTS[@]}" -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' "$pf"
"$SED" "${SEDOPTS[@]}" -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' "$pf"
done
When I run it with bash -x it prints eight errors. I can't figure out where the errors are coming from. Searching for the error provides one hit, but I don't quite see the solution.
Where is "gsed: can't read : No such file or directory" coming from?
Below, <full path> is /Users/<username>/<project name>/vs2005-dynamic/. There are no spaces in the pathname.
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/cryptdll.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/cryptdll.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ for pf in '"${PROJ_FILES[@]}"'
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/cryptest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/cryptest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ for pf in '"${PROJ_FILES[@]}"'
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/cryptlib.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/cryptlib.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ for pf in '"${PROJ_FILES[@]}"'
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="0"|RuntimeLibrary="2"|g' <full path>/dlltest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
+ /opt/local/bin/gsed -i '' -e 's|RuntimeLibrary="1"|RuntimeLibrary="3"|g' <full path>/dlltest.vcproj
/opt/local/bin/gsed: can't read : No such file or directory
<full path>include spaces? if so, thePROJ_FILES=($(find $PWD -name "*.vcproj"))construction will split them I think: you might want to try something likemapfile -t PROJ_FILES < <(find $PWD -name '*.vcproj')instead