rust_cmd_lib
Dev tools
shell scripting library
SHOW HN2020
How HN took it
5 positive, 10 neutral or asking, 1 mixed, 14 critical, out of 30 comments about the project. Thread score -0.07.
Idea: 4 for, 6 againstDesign: 1 for, 5 againstPrivacy: 0 for, 2 againstDocs: 0 for, 1 against
The thread, comment by comment
Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.
positive neutral or mixed critical about another commenter or something else the maker
What HN said
What people liked
Useful for mixing shell commands with text processing; hygienic approach to splicing commands
From 2 comments
I love this. I tried to do something similar in Go, because it was in use on my team at Airbnb, and we were looking to port a 2000 line make-and-bash tool to... something not…
jitl on HNMy god, this super useful when you have a mix o shell commands and processing text output from them. Bash isn’t particularly easy to work with parsing non-trivial strings in a…
yisonPylkita on HN
Better than bash for error handling and parsing
From 2 comments
This is so awesome! Any tips on parallelizing/is it async compatible? I personally found granular error handling combined with parallelization to be impossible to get just right…
implfuture on HNMy god, this super useful when you have a mix o shell commands and processing text output from them. Bash isn’t particularly easy to work with parsing non-trivial strings in a…
yisonPylkita on HN
Objections
Inlining shell code in Rust hides external command calls from auditing
From 3 comments
Please people, don’t do stuff like this for anything other than personal projects. You might think it’s safer than writing Bash but it isn’t. It results in unsafe Rust code since…
laumars on HNIt’s inside a .rs file so I don’t see how it’s not unsafe in the Rust sense. Maybe when I drew parallels with the “unsafe” block wasn’t fair but safety isn’t just about memory…
laumars on HN> I'll reiterate: it is often safer to embed short snippets of bash into other languages than to invert control and call out to other languages from bash. By calling out to bash,…
laumars on HN
Embedding a shell-like syntax in macros risks passing shell metacharacters to a shell
From 1 comment
I am not a huge fan of copying the shell language wholesale and wrapping inside a macro. Since macros can execute arbitrary code, this makes me feel uneasy that the strings are…
rhn_mk1 on HN
Shell is best kept as a DSL for files and streams; Rust macros unlikely to beat it
From 1 comment
``` > A lot developers just choose shell(sh, bash, ...) scripts for such tasks, > by using < to redirect input, > to redirect output and '|' to pipe outputs. > In my experience,…
geowwy on HN
Requests
Support for set -euxo pipefail style options
From 1 comment
This is great! What about "set -euxo pipefail"? I see you were using eprintln before the commands, could we have a "set" macro that would do that for us?
Fiahil on HN
Parallel and async support
From 1 comment
This is so awesome! Any tips on parallelizing/is it async compatible? I personally found granular error handling combined with parallelization to be impossible to get just right…
implfuture on HN
Questions
How are binary names resolved and does it use a shell
From 2 comments
I am not a huge fan of copying the shell language wholesale and wrapping inside a macro. Since macros can execute arbitrary code, this makes me feel uneasy that the strings are…
rhn_mk1 on HNAuthor here, thanks for your feedback. This library is calling std::process::command underneath without any shell dependency, which I believe is the same as plumbum’s run* APIs…
rustshellscript on HN
How does Rust parse the macro contents
From 1 comment
Interesting, it seems that it allows the exact syntax of shell commands, without using strings. ``` // valid rust code and shell code, no strings run_cmd!(du -ah . | sort -hr |…
gitgud on HN
Alternatives named
Plumbum (Python)
From 1 comment
I am not a huge fan of copying the shell language wholesale and wrapping inside a macro. Since macros can execute arbitrary code, this makes me feel uneasy that the strings are…
rhn_mk1 on HN
xonsh
From 1 comment
This reminds me of the python version of this called xonsh https://xon.sh/ I really like the idea, but it was missing some simple features that bash had. I can't recall them…
LockAndLol on HN
duct.rs
From 1 comment
I'm going to shamelessly plug my own library here: https://github.com/oconnor663/duct.rs I wanted to solve the same problem, originally in Python…
oconnor663 on HN
scriptisto
From 1 comment
There is also https://github.com/igor-petruk/scriptisto which would allow you to wrap any compiled language.
lugoues on HN
khaki
From 1 comment
I wrote a tool to do the opposite thing: allow writing "shell scripts" using Rust. Still early days but https://github.com/staktrace/khaki is where it lives.
staktrace on HN