bpo-45101: Add consistency in usage message IO between 2 versions of python-config (GH-28162)

On --help output to stdout.
On error output to stderr.
This commit is contained in:
Kien Dang 2024-02-27 03:04:44 +07:00 committed by GitHub
parent da382aaf52
commit de2a73dc46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View File

@ -0,0 +1 @@
Add consistency in usage message IO between 2 versions of python-config.

View File

@ -13,7 +13,8 @@ valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
def exit_with_usage(code=1):
print("Usage: {0} [{1}]".format(
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr)
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)),
file=sys.stdout if code == 0 else sys.stderr)
sys.exit(code)
try:

View File

@ -4,7 +4,12 @@
exit_with_usage ()
{
echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
local USAGE="Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir|--embed"
if [[ "$1" -eq 0 ]]; then
echo "$USAGE"
else
echo "$USAGE" >&2
fi
exit $1
}