Xshell: cross-platform utilities for ergonomic "bash" scripting

See the guide here:

Quick Example:

use xshell::{cmd, read_file};

let name = "Julia";
let output = cmd!("echo hello {name}!").read()?;
assert_eq!(output, "hello Julia!");

let err = read_file("feeling-lucky.txt").unwrap_err();
assert_eq!(
    err.to_string(),
    "`feeling-lucky.txt`: no such file or directory (os error 2)",
);
10 Likes

I like the idea :slightly_smiling_face: That is, something like ::duct was already quite nice, except for it bundling dependencies: given the purpose of using it for scripts / ad-hoc (compile-&-run) programs, both a certain amount of ergonomics and a lack of dependencies / fast from-scratch compile-times are paramount in order to minimize the impact on dev-time :ok_hand:

2 Likes

This looks great!

scriptisto, cargo-script, or even this hack would be great companions to this crate for creating scripts with Rust. They make it possible to create single-file Rust scripts that are re-compiled as needed.

1 Like

Love it. I'll keep that in mind for build automation scripts and the like!