JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

sh/$

sh


    macro
    /usr/local/lib/janet/sh.janet on line 258, column 1

    ($ & args)

    Run a process and abort on error.

    Returns nil for success, aborts on error.

    Example: `(sh/$ "ls" "-lh")`


2 examplesSign in to add an example
Loading...
# sh/$ can't expand "~" so you must build it:

# (def key "D8E4DB18BF87FLEW7402BBE3AA91B16F4A65C4C9") # use your gpg key ID
(defn copy-and-encrypt-password-store [key-id]
    (with [out (file/open "pass-backup.tar.gz.gpg" :w)]
        (sh/$ tar -czf - ,(string (os/getenv "HOME") "/.password-store") | gpg --encrypt --recipient ,key-id > ,out)))

# tar -cz ~/.password-store/ | gpg --encrypt --recipient YOUR_KEY_ID > pass-backup.tar.gz.gpg
veqqqPlayground

# sh/$'s contents are quasiquoted, allowing direct or string arguments
# so you need to unquote , variables:

(def out (file/open "trust-db.txt" :w))
(sh/$ "gpg" "--export-ownertrust" > ,out) # > requires an opened file object
(file/close out)

# note how > requires an opened file object
(with [out (file/open "trust-db.txt" :w)]
  (sh/$ gpg --export-ownertrust > ,out))
veqqqPlayground