This page is part of my digital garden.

This page might be unfinished or have typos. These pages are meant as part of a public living notebook to be edited over time. For more, visit the page explaining the concept of a digitial garden.

Scripting

Misc scripting things

Hush Lang Link to heading

New scripting language: https://hush-shell.github.io/

(hacker news discussion)

  • Written in Rust
  • Strongly Typed, Garbage collected, 1st class shell capabilities
  • Syntax a mix of Go, Rust, and Typescript; “Inspired by Lua”
  • Provides standard library std with common functions and constants
  • Proper if, for, and while. Built in list and dict types.
  • dict can have function values for keys (aka “a method” sort of)
  • syntax errors panic and app errors return std.error("...")
    • adding a ? to something which may return an error panics if an error is returned.
  • execute commands in “command blocks”: { touch /etc/config }
    • can return a proper “std.error” type or a result
    • multiple commands per block delimited by ;
    • supports pipelines and redirection using standard syntax
    • variables defined outside can be used using $var / ${var} / etc.
    • error in any command stops unless followed by a ? (opposite behavior to in normal lang)
  • supports launching command blocks async using let handle = &{...} and handle.join() to wait for completion
function run()
    { mkdir /etc/config/ }?
    std.print("Success!") # This won't be executed if the command block fails.
end

let result = run()
if std.type(result) == "error" then
    std.print("Error: ", result)
end

Bash one-line script; Print “sleep” every 10 seconds forever Link to heading

bash -c while true; do echo sleep; sleep 10;done && echo done

Needed this once because I needed to run a custom command in a Fargate task with two “essential” containers. One of those containers would exit immediately which would interrupt the other command which was migrating the database so I wrote this up to have it “do nothing” without spending too much CPU.

Last updated on