为什么aws --version写入stderr?

riv*_*all 2 amazon-ec2 amazon-web-services aws-cli

为什么标准检查aws --version会将预期输出打印到stderr,而不是stdout?

$ aws --version 2>err.log
$ cat err.log
aws-cli/1.11.65 Python/2.7.13 Darwin/16.5.0 botocore/1.5.28
$ aws --version > out.log
aws-cli/1.11.65 Python/2.7.13 Darwin/16.5.0 botocore/1.5.28
$ cat out.log
$
Run Code Online (Sandbox Code Playgroud)

如果命令成功完成,将结果写入stdout是有意义的.其他命令aws ec2 describe-images或者aws ec2 describe-instances正确地将输出写入stdout.

检查CentOS和MacOS.

jar*_*mod 7

这是由Python 3.4中修复的argparse中的错误引起的.

awscli是用Python编写的,它使用argparse模块来解析命令行.它还使用argparse 的action="version" 功能来简化版本打印.这将在Python 3.4之前将版本字符串打印到stderr,并在Python 3.4+中打印到stdout.