それはと私と一緒に動作します '$?'
$ git push origin master
Username for 'https://github.com': sld,sldk
Password for 'https://sld,[email protected]':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/KamelHacene/configeuh.git/'
$ echo $?
128
コマンドが成功した場合は、$? (var = $?のような)変数にキャッチするだけでよいでしょう。
ちょうどこの(標準エラー出力をファイルに)のようなあなたのエラー出力をリダイレクトし、エラーメッセージをキャッチする:
$ git push origin master 2>plop
Username for 'https://github.com': lskdls
Password for 'https://[email protected]':
$ cat plop
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/KamelHacene/configeuh.git/'
またはこの(stdoutに標準エラー出力標準出力をキャッチするために変数を使用してください。):
$ ploop=$(git push origin master 2>&1)
Username for 'https://github.com': skjdksd
Password for 'https://[email protected]':
$ echo $ploop
remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/KamelHacene/configeuh.git/'
ありがとう!それは働いている! – n0z