diff options
author | John Turner <jturner.usa@gmail.com> | 2025-09-18 05:11:51 -0400 |
---|---|---|
committer | John Turner <jturner.usa@gmail.com> | 2025-09-18 05:49:16 -0400 |
commit | a3d35b6318332577ef8aa2699e27c0c52cdeeb3a (patch) | |
tree | 8768ff77c46aac73ece6dcde3beb3e0daa7f06f0 | |
parent | eb4c401fe425afabfd28d154d02dad86bad2e989 (diff) | |
download | pypaste-a3d35b6318332577ef8aa2699e27c0c52cdeeb3a.tar.gz |
check subcommand status code and print its stderr on failure
-rw-r--r-- | pypaste/client/__main__.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pypaste/client/__main__.py b/pypaste/client/__main__.py index d424603..fabf50c 100644 --- a/pypaste/client/__main__.py +++ b/pypaste/client/__main__.py @@ -79,6 +79,14 @@ def main() -> int: elif (command := args.command) is not None: cmd = shlex.split(command, posix=True) proc = subprocess.run(cmd, capture_output=True, text=True, shell=True) + + if proc.returncode != 0: + print( + f"{command} failed with exit code: {proc.returncode}:{proc.stdout}", + file=sys.stderr, + ) + return 1 + text = f"# {command}\n{proc.stdout}" else: return 0 |