Skip to content

Commit

Permalink
Fix #112: pre-start-fn in exec (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored May 4, 2023
1 parent dadcff4 commit 4238230
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
[Babashka process](https://github.com/babashka/process)
Clojure library for shelling out / spawning sub-processes

## Unreleased

- Fix [#112](https://github.com/babashka/process/issues/112): pre-start-fn in exec

## 0.4.16

- [#100](https://github.com/babashka/process/issues/100): preserve single-quotes in double-quoted string
Expand Down
18 changes: 13 additions & 5 deletions src/babashka/process.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,9 @@
{:arglists '([opts? & args])}
[& args]
(let [{:keys [cmd opts]} (parse-args args)]
(let [{:keys [escape env extra-env]
:or {escape default-escape}
(let [{:keys [escape env extra-env pre-start-fn]
:or {escape (:escape *defaults*)
pre-start-fn (:pre-start-fn *defaults*)}
:as opts} opts
cmd (if (and (string? cmd)
(not (.exists (io/file cmd))))
Expand All @@ -585,9 +586,13 @@
cmd (mapv str-fn cmd)
arg0 (or (:arg0 opts)
(first cmd))
cmd (let [program-resolver (:program-resolver opts -program-resolver)
[program & args] cmd]
program-resolver (or (:program-resolver opts)
(:program-resolver *defaults*))
cmd (let [[program & args] cmd]
(into [(program-resolver program)] args))
_ (when pre-start-fn
(let [interceptor-map {:cmd cmd}]
(pre-start-fn interceptor-map)))
[program & args] cmd
args (cons arg0 args)
^java.util.Map env (into (or env (into {} (System/getenv))) extra-env)]
Expand All @@ -609,7 +614,10 @@
while the process runs. Throws on non-zero exit codes. Kills all
subprocesses on shutdown. Optional options map can be passed as the
first argument, followed by multiple command line arguments. The
first command line argument is automatically tokenized.
first command line argument is automatically tokenized. Counter to
what the name of this function may suggest, it does not start a
new (bash, etc.) shell, it just shells out to a program. As such, it
does not support bash syntax like `ls *.clj`.
Examples:
Expand Down

0 comments on commit 4238230

Please sign in to comment.