summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-09-18 05:11:51 -0400
committerJohn Turner <jturner.usa@gmail.com>2025-09-18 05:49:16 -0400
commita3d35b6318332577ef8aa2699e27c0c52cdeeb3a (patch)
tree8768ff77c46aac73ece6dcde3beb3e0daa7f06f0
parenteb4c401fe425afabfd28d154d02dad86bad2e989 (diff)
downloadpypaste-a3d35b6318332577ef8aa2699e27c0c52cdeeb3a.tar.gz
check subcommand status code and print its stderr on failure
-rw-r--r--pypaste/client/__main__.py8
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