1
我有我的make文件這個食譜:配方似乎忽略條件內環
.PHONY: matlab
matlab: $(matlab_files)
set -x;for f in `echo "$^"`; do\
base=`basename $$f`;\
if [[ ! -f "$(matlab_dir_name)/$${base}" ]]; then\
ln -s $$f $(matlab_dir_name)/$${base}; \
fi;\
done;set +x
就是,我要檢查,如果鏈接使得它之前就存在。但是,如果測試似乎被忽略。通過上面顯示的調試選項,我得到以下幾行:
+ for f in '`echo "MatlabD3PDImport/matlab/d3pd_export.m MatlabD3PDImport/matlab/matd3pd.m MatlabD3PDImport/matlab/net2py.m MatlabRingerTrain/matlab/cluster_size.m MatlabRingerTrain/matlab/create_cluster.m MatlabRingerTrain/matlab/getEffAtThres.m MatlabRingerTrain/matlab/getThresAndEff.m MatlabRingerTrain/matlab/scanparam.m MatlabRingerTrain/matlab/script_normal_train_offline.m MatlabRingerTrain/matlab/trainBinaryClassifier.m MatlabRingerTrain/matlab/trainRinger.m MatlabRingerTrain/matlab/xValidateBinaryClassifier.m"`'
++ basename MatlabRingerTrain/matlab/scanparam.m
+ base=scanparam.m
+ [[ ! -f matlab/scanparam.m ]]
+ ln -s MatlabRingerTrain/matlab/scanparam.m matlab/scanparam.m
ln: matlab/scanparam.m: File exists
+ for f in '`echo "MatlabD3PDImport/matlab/d3pd_export.m MatlabD3PDImport/matlab/matd3pd.m MatlabD3PDImport/matlab/net2py.m MatlabRingerTrain/matlab/cluster_size.m MatlabRingerTrain/matlab/create_cluster.m MatlabRingerTrain/matlab/getEffAtThres.m MatlabRingerTrain/matlab/getThresAndEff.m MatlabRingerTrain/matlab/scanparam.m MatlabRingerTrain/matlab/script_normal_train_offline.m MatlabRingerTrain/matlab/trainBinaryClassifier.m MatlabRingerTrain/matlab/trainRinger.m MatlabRingerTrain/matlab/xValidateBinaryClassifier.m"`'
++ basename MatlabRingerTrain/matlab/script_normal_train_offline.m
+ base=script_normal_train_offline.m
+ [[ ! -f matlab/script_normal_train_offline.m ]]
+ ln -s MatlabRingerTrain/matlab/script_normal_train_offline.m matlab/script_normal_train_offline.m
ln: matlab/script_normal_train_offline.m: File exists
+ for f in '`echo "MatlabD3PDImport/matlab/d3pd_export.m MatlabD3PDImport/matlab/matd3pd.m MatlabD3PDImport/matlab/net2py.m MatlabRingerTrain/matlab/cluster_size.m MatlabRingerTrain/matlab/create_cluster.m MatlabRingerTrain/matlab/getEffAtThres.m MatlabRingerTrain/matlab/getThresAndEff.m MatlabRingerTrain/matlab/scanparam.m MatlabRingerTrain/matlab/script_normal_train_offline.m MatlabRingerTrain/matlab/trainBinaryClassifier.m MatlabRingerTrain/matlab/trainRinger.m MatlabRingerTrain/matlab/xValidateBinaryClassifier.m"`'
++ basename MatlabRingerTrain/matlab/trainBinaryClassifier.m
+ base=trainBinaryClassifier.m
+ [[ ! -f matlab/trainBinaryClassifier.m ]]
+ ln -s MatlabRingerTrain/matlab/trainBinaryClassifier.m matlab/trainBinaryClassifier.m
ln: matlab/trainBinaryClassifier.m: File exists
+ for f in '`echo "MatlabD3PDImport/matlab/d3pd_export.m MatlabD3PDImport/matlab/matd3pd.m MatlabD3PDImport/matlab/net2py.m MatlabRingerTrain/matlab/cluster_size.m MatlabRingerTrain/matlab/create_cluster.m MatlabRingerTrain/matlab/getEffAtThres.m MatlabRingerTrain/matlab/getThresAndEff.m MatlabRingerTrain/matlab/scanparam.m MatlabRingerTrain/matlab/script_normal_train_offline.m MatlabRingerTrain/matlab/trainBinaryClassifier.m MatlabRingerTrain/matlab/trainRinger.m MatlabRingerTrain/matlab/xValidateBinaryClassifier.m"`'
++ basename MatlabRingerTrain/matlab/trainRinger.m
+ base=trainRinger.m
+ [[ ! -f matlab/trainRinger.m ]]
+ ln -s MatlabRingerTrain/matlab/trainRinger.m matlab/trainRinger.m
ln: matlab/trainRinger.m: File exists
+ for f in '`echo "MatlabD3PDImport/matlab/d3pd_export.m MatlabD3PDImport/matlab/matd3pd.m MatlabD3PDImport/matlab/net2py.m MatlabRingerTrain/matlab/cluster_size.m MatlabRingerTrain/matlab/create_cluster.m MatlabRingerTrain/matlab/getEffAtThres.m MatlabRingerTrain/matlab/getThresAndEff.m MatlabRingerTrain/matlab/scanparam.m MatlabRingerTrain/matlab/script_normal_train_offline.m MatlabRingerTrain/matlab/trainBinaryClassifier.m MatlabRingerTrain/matlab/trainRinger.m MatlabRingerTrain/matlab/xValidateBinaryClassifier.m"`'
++ basename MatlabRingerTrain/matlab/xValidateBinaryClassifier.m
+ base=xValidateBinaryClassifier.m
+ [[ ! -f matlab/xValidateBinaryClassifier.m ]]
+ ln -s MatlabRingerTrain/matlab/xValidateBinaryClassifier.m matlab/xValidateBinaryClassifier.m
ln: matlab/xValidateBinaryClassifier.m: File exists
+ set +x
爲什麼shell忽略if測試?
謝謝,我只是發現錯誤與符號鏈接,因爲matlab有運行符號鏈接的麻煩。我將它改爲硬鏈接,'-f'測試和matlab都能識別這個文件。幸運的是,您的答案只是提供了所有缺乏關閉該線程的信息。 – Werner 2014-09-28 03:21:12