Skip to content

Commit

Permalink
Fix a bug with inherited stdout in basilisp.process/exec (#1191)
Browse files Browse the repository at this point in the history
Fixes #1190
  • Loading branch information
chrisrink10 authored Dec 23, 2024
1 parent 54b340a commit 5525a69
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
* Fix a bug in `defn` where the `attr-map?` and function metdata were merged into a seq instead of a map, causing `macroexpand` to fail in some cases (#1186)
* Fix a bug where `basilisp.process/exec` threw an exception when inheriting the stdout stream from the current process (#1190)

## [v0.3.5]
### Changed
Expand Down
4 changes: 3 additions & 1 deletion src/basilisp/process.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@
(let [process (apply start opts+args)
retcode (.wait process)]
(if (zero? retcode)
(slurp (.-stdout process))
(if-let [out (.-stdout process)]
(slurp out)
"")
(throw
(subprocess/CalledProcessError retcode
(.-args process)
Expand Down
1 change: 1 addition & 0 deletions tests/basilisp/test_process.lpy
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@

(deftest exec-test
(is (= "" (process/exec sys/executable "-c" "pass")))
(is (= "" (process/exec {:out :inherit} sys/executable "-c" "print(\"hi\")")))
(is (= "" (process/exec sys/executable "-c" "import sys; print(\"hi\", file=sys.stderr)")))
(is (= "hi\n" (process/exec sys/executable "-c" "print(\"hi\")")))
(is (thrown? subprocess/CalledProcessError
Expand Down

0 comments on commit 5525a69

Please sign in to comment.