Expand

run

execute a command immediately

<run> = run <command>

run is mostly used for situation when a command is stored in a variable or when a command name needs to be escaped. run always evaluates its arguments from left to right.

a command name can't start with a digit, hence name should be quoted run "7z" e examples.7z
execute a command based on extension
fn exec-script $script $args... {
    $interp := {
        py: "python",
        sh: "bash",
        sy: "sy",
    }
    $ext := $script:dots[-1]
    if $ext not in $interp {
        panic "unknown extension $ext"
    }
    run $interp[$ext] $script $args...
}
execute a function from a variable. wrap remembers a command and its arguments and creates a 'wrap', which can be called later
$func := wrap print "Crash!"
run $func "Boom!"

See Also