소스 정보
- 저장소
- hugoduncan/library-skills
- 최근 소스 활동
- 2026년 1월 17일 13:40
- 감지된 SKILL.md 언어
- 영어
- 스타
- 3
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/hugoduncan/library-skills --skill babashkaprocess명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
REPL-friendly data visualization and literate programming for Clojure with Kindly convention
Pure Clojure/Script logging library with flexible configuration and powerful features
Django-inspired HTML templating system for Clojure with filters, tags, and template inheritance
SOC 직업 분류 기준
SKILL.md 표시 중
| name | babashka.process |
| description | Clojure library for spawning sub-processes and shell operations |
A Clojure library for shelling out and spawning sub-processes. Wraps java.lang.ProcessBuilder with an ergonomic API supporting pipelines, streaming I/O, and process control.
babashka.process provides two main entry points:
shell - High-level convenience function with sensible defaultsprocess - Low-level function for fine-grained controlIncluded in Babashka since v0.2.3. Also usable as a JVM library.
Repository: https://github.com/babashka/process
;; deps.edn
{:deps {babashka/process {:mvn/version "0.6.25"}}}
Built into Babashka - no installation needed for bb scripts.
| Aspect | shell | process |
|---|---|---|
| Blocking | Yes | No (returns immediately) |
| Exit check | Throws on non-zero | No checking |
| I/O default | :inherit (console) | Streams |
| Tokenization | Auto-tokenizes first arg | Manual |
Use shell for simple commands. Use process for pipelines, streaming, or async operations.
Both functions return a record containing:
:proc - java.lang.Process instance:in - Input stream (stdin):out - Output stream (stdout):err - Error stream (stderr):cmd - Command vector:prev - Previous process (pipelines)Dereferencing (@ or deref) waits for completion and adds :exit.
High-level function for running external programs.
(require '[babashka.process :refer [shell]])
;; Basic usage - tokenizes automatically
(shell "ls -la")
;; Multiple arguments
(shell "git" "commit" "-m" "message")
;; With options
(shell {:dir "src"} "ls")
;; Capture output
(-> (shell {:out :string} "echo hello") :out)
;; => "hello\n"
;; Continue on error (don't throw)
(shell {:continue true} "ls nonexistent")
Options:
:continue - Don't throw on non-zero exitprocess options supportedLow-level function with no opinionated defaults.
(require '[babashka.process :refer [process]])
;; Returns immediately
(def p (process "sleep" "5"))
;; Deref to wait and get exit code
(:exit @p)
;; Capture output
(->> (process {:out :string} "ls") deref :out)
Wait for process and throw on non-zero exit.
(require '[babashka.process :refer [process check]])
;; Throws if ls fails
(->> (process {:out :string} "ls") check :out)
;; Chain with process
(-> (process "make") check)
Convenience wrapper defaulting :out and :err to :string.
(require '[babashka.process :refer [sh]])
(sh "ls" "-la")
;; => {:exit 0 :out "..." :err ""}
Macro for shell-like syntax with interpolation.
(require '[babashka.process :refer [$]])
(def file "README.md")
($ ls -la ~file)
;; With options via metadata
(^{:out :string} $ echo hello)
Split string into argument vector.
(require '[babashka.process :refer [tokenize]])
(tokenize "ls -la")
;; => ["ls" "-la"]
(tokenize "echo 'hello world'")
;; => ["echo" "hello world"]
Check if process is running.
(require '[babashka.process :refer [process alive?]])
(def p (process "sleep" "10"))
(alive? p) ;; => true
Terminate process. destroy-tree also kills descendants (JDK9+).
(require '[babashka.process :refer [process destroy destroy-tree]])
(def p (process "sleep" "100"))
(destroy p)
;; Kill process and all children
(destroy-tree p)
Replace current process image (GraalVM/Babashka only).
(require '[babashka.process :refer [exec]])
;; Replaces bb process with ls
(exec "ls" "-la")
Create process builders for pipelines.
(require '[babashka.process :refer [pb pipeline]])
;; JDK9+ pipeline
(-> (pipeline (pb "cat" "file.txt")
(pb "grep" "pattern")
(pb "wc" "-l"))
last
deref
:out
slurp)
| Option | Values | Description |
|---|---|---|
:in | stream, string, :inherit | Stdin source |
:out | :string, :bytes, :inherit, :write, :append, file | Stdout destination |
:err | Same as :out, plus :out to merge | Stderr destination |
:in-enc | charset | Input encoding |
:out-enc | charset | Output encoding |
:err-enc | charset | Error encoding |
| Option | Description |
|---|---|
:dir | Working directory |
:env | Replace environment (map) |
:extra-env | Add to environment (map) |
:inherit | If true, inherit all streams |
:cmd | Command vector (overrides args) |
:prev | Previous process for piping |
| Option | Description |
|---|---|
:pre-start-fn | Called before start with process info |
:shutdown | Called when child process ends |
:exit-fn | Called on exit (JDK11+) |
;; As string
(-> (shell {:out :string} "date") :out str/trim)
;; As bytes
(-> (shell {:out :bytes} "cat" "image.png") :out)
;; Merge stderr into stdout
(shell {:err :out :out :string} "cmd")
(shell {:dir "/tmp"} "ls")
;; Add to environment
(shell {:extra-env {"DEBUG" "1"}} "./script.sh")
;; Replace environment
(shell {:env {"PATH" "/usr/bin"}} "ls")
;; Using threading
(->> (process "cat" "file.txt")
(process {:out :string} "grep" "pattern")
deref
:out)
;; Using pipeline (JDK9+)
(-> (pipeline (pb "ls") (pb "grep" "clj"))
last deref :out slurp)
;; String input
(-> (process {:in "hello\nworld" :out :string} "cat")
deref :out)
;; File input
(-> (process {:in (io/file "data.txt") :out :string} "wc")
deref :out)
For processes that read stdin until EOF, close it immediately:
;; Empty string - simplest approach
(process {:in ""} "cmd")
;; Null device
(process {:in null-file} "cmd")
;; Explicit close after start
(let [p (process "cmd")]
(.close (:in p))
p)
(require '[clojure.java.io :as io])
(def p (process {:err :inherit} "bb" "-e" "(doseq [i (range)] (println i) (Thread/sleep 100))"))
(with-open [rdr (io/reader (:out p))]
(doseq [line (line-seq rdr)]
(println "Got:" line)))
(def p (process "cat"))
(def w (io/writer (:in p)))
(binding [*out* w]
(println "hello")
(println "world"))
(.close w)
(slurp (:out p))
;; => "hello\nworld\n"
;; Overwrite
(shell {:out :write :out-file "log.txt"} "ls")
;; Append
(shell {:out :append :out-file "log.txt"} "date")
(require '[babashka.process :refer [shell null-file]])
(shell {:out null-file :err null-file} "noisy-command")
(let [p (process "sleep" "100")]
(when-not (deref p 1000 nil)
(destroy-tree p)
(println "Timed out")))
(shell {:pre-start-fn (fn [{:keys [cmd]}]
(println "Running:" cmd))}
"ls")
;; shell throws by default
(try
(shell "ls" "nonexistent")
(catch Exception e
(println "Failed:" (ex-message e))))
;; Suppress with :continue
(let [{:keys [exit]} (shell {:continue true} "ls" "nonexistent")]
(when-not (zero? exit)
(println "Command failed")))
;; Manual checking with process
(let [{:keys [exit out err]} @(process {:out :string :err :string} "cmd")]
(if (zero? exit)
(println "Success:" out)
(println "Error:" err)))
(let [{:keys [err]} (shell {:err :string :continue true} "ls" "nonexistent")]
(println "Error output:" err))
:string for large data; stream insteadpb oncedestroy-tree - Prevent zombie processes when killing:extra-env.ps1 scripts directly; invoke through PowerShell:
(shell "powershell" "-File" "script.ps1")
tokenize explicitly when needed| Feature | clojure.java.shell/sh | babashka.process |
|---|---|---|
| Blocking | Always | Explicit via deref |
| Piping | No | Yes |
| Streaming | No | Yes |
| Process control | Limited | Full access |
| Exit checking | Manual | check / shell |