OS X에서 간단한 교체를 수행하는 Bash 스크립트가 있습니다. 단순화된 상황은 다음과 같습니다.
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
실행하면 bash -x
8개의 오류가 인쇄됩니다. 오류가 어디서 발생하는지 알 수 없습니다. 오류를 찾는 중히트를 치다, 그러나 솔루션을 잘 이해하지 못합니다.
어디"gsed: 읽을 수 없습니다: 해당 파일이나 디렉터리가 없습니다."어디서?
아래 <full path>
는 입니다 /Users/<username>/<project name>/vs2005-dynamic/
. 경로 이름에는 공백이 없습니다.
+ /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
답변1
gsed를 사용하면 추가 ''가 필요하지 않으며 기본 OSX sed를 사용하면 됩니다. 다음 방법 중 하나를 시도해 보십시오.
SED=/usr/bin/sed
또는:
SEDOPTS=(-i)