如果我运行此代码:
svn_output = %x[svn update /Users/radek/Sites/db2.rft -r 11105 --force ] puts puts " output is =#{svn_output}="
我得到了这个结果
svn: Working copy '/Users/radek/Sites/db2.rft' locked svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details) output is ==
但我希望变量svn_output中的svn出现错误消息.那可能吗?
解决方法
您想将stderr重定向到stdout:
svn_output = %x[svn update /Users/radek/Sites/db2.rft -r 11105 --force 2>&1] puts puts " output is =#{svn_output}="