From a3d35b6318332577ef8aa2699e27c0c52cdeeb3a Mon Sep 17 00:00:00 2001 From: John Turner Date: Thu, 18 Sep 2025 05:11:51 -0400 Subject: check subcommand status code and print its stderr on failure --- pypaste/client/__main__.py | 8 ++++++++ 1 file changed, 8 insertions(+) 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 -- cgit v1.2.3