2017-02-07 9 views
1

私はドキュメントとしてsphinxを使用しています。 make htmlを使い、latexpdfをbashスクリプトを通して作っています。 bashスクリプトを実行すると、make htmlを実行すると、読み込み元の後に最初のファイルにERRORが表示されます。ソースを読んでいるときにスフィンクスのキャッチエラーが発生しました

make clean 
+ make clean 
rm -rf _build/* 
make html 
+ make html 
sphinx-build -b html -d _build/doctrees . _build/html 
Running Sphinx v1.3b3 
making output directory... 
loading pickled environment... not yet created 
building [mo]: targets for 0 po files that are out of date 
building [html]: targets for 2 source files that are out of date 
updating environment: 2 added, 0 changed, 0 removed 
reading sources... [100%] index 
/home/sphinx/Inder.rst:12:WARNING: Bullet list ends without a blank line; unexpected unindent. 
/home/sphinx/Inder.rst:12: ERROR: Document may not end with a transition. 
looking for now-outdated files... none found 
pickling environment... done 
checking consistency... done 
preparing documents... done 
writing output... [100%] index     

このエラーをbashスクリプトで検出したり、別の変数に送信したりするにはどうすればよいですか。 make htmlでgrep ERRORを試しましたが、空白になります。

+0

'ちょうどstdout''で表示から非表示にするとして、それをout'はgrep? – Inian

+0

[最小限で完全で検証可能なサンプルの作成方法](http://stackoverflow.com/help/mcve)をご覧ください。 – Cyrus

+0

私はこのようなものを使用することを意味しました - RESULT = make html | grep ERROR。 私はそれを変数に格納し、変数にエラーが含まれているかどうかをチェックすることができます。そうでなければ続行する。 –

答えて

1

sphinx-buildおそらく両方のストリームをキャプチャしたいと思うので、stdoutとstderrの両方に出力を出力します。

次のような操作を行うことができます。

out=$(make html 2>&1) 
if grep -q 'ERROR: ' <<< "$out"; then 
    # do some error handling 
fi 
関連する問題