分页: 1 / 1

shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:09
lysygyy
export

CODESIGN_ALLOCATE=/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platf

orm/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ] || [ "${PLATFORM_NAME}" ==

"ipados" ]; then
/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py

"my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/

${PROJECT_NAME}.xcent";
codesign -f -s "iPhone Developer" --entitlements

"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent"

"${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"

fi

以上为运行的脚本,请问哪里错了啊,本人第一次接触shell,不懂啊。

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:14
eexpress
你这是分行的?还是不分行的?不分行,需要加;号。

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:18
lysygyy
eexpress 写了:你这是分行的?还是不分行的?不分行,需要加;号。
不太明白你的意思,这不就是if then fi语句嘛,能不能帮忙改一下啊!

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:25
lysygyy
export

CODESIGN_ALLOCATE=/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ] || [ "${PLATFORM_NAME}" == "ipados" ]; then
/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"

fi

改成了上面的脚本,还是不行啊,还是提示错误:
/Users/mahmood1/Library/Developer/Xcode/DerivedData/HYGisManager-clgaxawbmlqfidbpvgnkgkmjmbca/Build/Intermediates/HYGisManager.build/Release-iphonesimulator/HYGisManager.build/Script-F267E10C158984970053F892.sh: line 6: syntax error near unexpected token `fi'
/Users/mahmood1/Library/Developer/Xcode/DerivedData/HYGisManager-clgaxawbmlqfidbpvgnkgkmjmbca/Build/Intermediates/HYGisManager.build/Release-iphonesimulator/HYGisManager.build/Script-F267E10C158984970053F892.sh: line 6: `fi'
Command /bin/sh failed with exit code 2

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:29
eexpress
你按照code贴吧。看不出。
if [ xx ] then; yyyy; fi

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:32
lysygyy
怎么没人回答呢?急呀!先顶上去再说!

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-14 14:34
lysygyy

代码: 全选

export

CODESIGN_ALLOCATE=/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
if [ "${PLATFORM_NAME}" == "iphoneos" ] || [ "${PLATFORM_NAME}" == "ipados" ]; then
/Xcode.app/Contents/Developer/iphoneentitlements/gen_entitlements.py "my.company.${PROJECT_NAME}" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent";
codesign -f -s "iPhone Developer" --entitlements "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/${PROJECT_NAME}.xcent" "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}/"

fi

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-06-17 3:05
naturalaw
ee的意思很明白了的嘛。
两种写法
$ if [ 1 -gt 0 ];then
> echo hi
> fi
hi
$ if [ 1 -gt 0 ]
> then echo hi
> fi
hi

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-07-14 15:13
chenbiren
你确定是bash脚本?不是C shell TC shell其他的像C shell就不是fi

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-07-14 15:30
chenbiren
你确定是bash脚本?不是C shell TC shell其他的像C shell就不是fi

Re: shell脚本出错:syntax error near unexpected token `fi'

发表于 : 2012-07-15 6:44
aerofox
有可能脚本文件采用了DOS格式的换行,不过要 fi 后正好有个空格才行吧。最好把脚本文件已附件的形式贴上来看看。

与报的错无关的问题:export 应该与下面的赋值在同一行。