鉴于这种(中更多...):bash命令路径故障
compile_coffee() {
echo "Compile COFFEESCRIPT files..."
i=0
for folder in ${COFFEE_FOLDER[*]}
do
for file in $folder/*.coffee
do
file_name=$(echo "$file" | awk -F "/" '{print $NF}' | awk -F "." '{print $1}')
file_destination_path=${COFFEE_DESTINATION_FOLDER[${i}]}
file_destination="$file_destination_path/$file_name.js"
if [ -f $file_path ]; then
echo "+ $file -> $file_destination"
$COFFEE_CMD $COFFEE_PARAMS $file > $file_destination #FAIL
#$COFFEE_CMD $COFFEE_PARAMS $file > testfile
fi
done
i=$i+1
done
echo "done!"
compress_javascript
}
而只是为了澄清,除了#FAIL线一切正常flawessly,如果我做错了就告诉我,在问题我已经是:
- 行执行和做的事情必须做,但不写,我把在“file_destination”的文件。
- 如果删除该路由中的一个文件夹(它与此脚本有关,请参见下文),bash将抛出错误并指出该文件夹不存在。
- 如果我再次创建文件夹,没有错误,但没有文件。
- 如果我将$ file_destination更改为“testfile”,它会创建具有正确内容的文件。
- $ file_destination路径正常 - 如您所见,我的脚本会回应它 -
- 如果我回显整行,请使用params复制确切的命令并将其执行到脚本所在的目录中的shell上,它 的作品。
我不知道什么是错,一直在琢磨了两个小时......
脚本输出(实际路径):
(alpha)[[email protected] herobrine]$ ./deploy.sh compile && ls -l database/static/js/
===============================
=== Compile ===
Compile COFFEESCRIPT files...
+ ./database/static/coffee/test.coffee -> ./database/static/js/test.js
done!
Linking static files to django staticfiles folder... done!
total 0
完成命令:
coffee --compile --print ./database/static/coffee/test.coffee > ./database/static/js/test.js
我错过了什么?
编辑我已经做了一些改进。 在shell中,如果我禁用python virtualenv脚本,但如果我从脚本中调用deactivate它说没有找到命令。
运行脚本之前是否存在'./ database/static/js'? – beny23