aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2026-01-17 11:55:32 -0600
committerCalvin Rose <calsrose@gmail.com>2026-01-17 11:55:32 -0600
commitc675493530e86f85600c5798f3f1e9111a306de8 (patch)
treeb2f61bf6b5f9876a78a9403581fcc28bd7cf0b11 /doc
parentTurn off sh-dsl tests for windows temporarily. (diff)
More work on sh-dsl documentation.
Diffstat (limited to 'doc')
-rw-r--r--doc/api/sh-dsl.mdz29
1 files changed, 27 insertions, 2 deletions
diff --git a/doc/api/sh-dsl.mdz b/doc/api/sh-dsl.mdz
index 82251c4..74c64fd 100644
--- a/doc/api/sh-dsl.mdz
+++ b/doc/api/sh-dsl.mdz
@@ -50,8 +50,7 @@ variables from the calling process can also be passed in by passing in symbols t
Keep in mind that this syntax is not the same as Posix shell - environment variable expansion will not work everywhere and
can always be substituted with inline Janet code instead.
-
-### Janet Substitution
+### Janet Expression Substitution
Users may want to mix Janet expressions with literals when invoking subprograms, and this library makes it easy
using the familiar @code`unquote` special.
@@ -75,6 +74,32 @@ using the familiar @code`unquote` special.
($ echo '(+ 1 2 3))
```
+### Pipes
+
+The input of one command can be piped into another as in shell scripts.
+
+@codeblock[janet]```
+(use spork/sh-dsl)
+
+($ ip address | grep docker)
+(json/decode ($<_ curl -s https://www.githubstatus.com/api/v2/status.json | jq .))
+```
+
+## File Redirection
+
+Standard IO (stdin, stdout, and stderr) can also be redirect to files much like the usual shell syntax.
+
+@codeblock[janet]```
+(use spork/sh-dsl)
+
+($ echo hi > out.txt) # Returns 0 and outputs nothing to the console - output has been redirected.
+($ cat out.txt) # prints hi
+($ janet -e '(error :oops) :err-to-out > out.txt) # redirect stderr to stdout
+($ janet -e '(error :oops) :err-to-out >> out.txt) # redirect stderr to stdout and append to out.txt instead of overwriting
+
+($ janet -e '(prin (:read stdin :all)) < out.txt) # reprint out.txt
+```
+
## Reference
@api-docs("../../spork" "sh-dsl")