Reputation: 840
Why standard check aws --version
prints the expected output to the stderr, not 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
$
It would make sense to write the result into stdout if command completed successfully. Other commands like aws ec2 describe-images
or aws ec2 describe-instances
write the output to the stdout correctly.
Checked on CentOS and MacOS.
Upvotes: 3
Views: 756
Reputation: 78842
This is caused by a bug in argparse that was fixed in Python 3.4.
The awscli is written in Python and it uses the argparse module to parse the command line. It also uses the action="version"
feature of argparse to simplify version printing. This prints the version string to stderr prior to Python 3.4 and prints to stdout in Python 3.4+.
Upvotes: 7