该脚本不适用于“?” 案子。当我直接在命令行中运行时......工作正常但在脚本中无法运行“?” 健康)状况。
svn st svn_promote_WP
M svn_promote_WP\Code\Environment\DEV\properties\build.properties
M svn_promote_WP\Code\Environment\RT\properties\build.properties
? svn_promote_WP\props.pl
这是我的脚本:
#!/usr/bin/sh
meta_data=(`svn st svn_promote_WP | cut -c1`)
meta_files=(`svn st svn_promote_WP | awk '$1~/^[AMD?]$/{for(i=2;i<=NF;i++)print $i}'`)
for index in ${!meta_data[*]}
do
if [ ${meta_data[$index]} = "?" ]; then
echo "${meta_files[$index]} need to be added"
elif [ ${meta_data[$index]} = "M" ]; then
echo "${meta_files[$index]} are modified"
fi
done
输出:
svn_promote_WP\Code\Environment\DEV\properties\build.properties are modified
svn_promote_WP\Code\Environment\RT\properties\build.properties are modified
期望的输出:
svn_promote_WP\Code\Environment\DEV\properties\build.properties are modified
svn_promote_WP\Code\Environment\RT\properties\build.properties are modified
svn_promote_WP\props.pl need to be added
更新了更多详细信息 - 在命令行上运行时的结果:
$ svn st svn_promote_WP | cut -c1
M
M
?
$ svn st svn_promote_WP | awk '$1~/^[AMD?]$/{for(i=2;i<=NF;i++)print $i}'
svn_promote_WP\Code\Environment\DEV\properties\build.properties
svn_promote_WP\Code\Environment\RT\properties\build.properties
svn_promote_WP\props.pl