Re:Crush: A command line shell that is also a powerful moder...
by adamnew123456 on Friday August 07, 2020 @09:17AM
(#24081439)
If you're open to learning it, Tcl is actually a good middle ground here. The
best way I can describe it is "structured shell script" - still very string
oriented, but the syntax and command set is much more well thought out, and
its better for building libraries in (having namespacing, among other things).
You even have a choice among object systems if you need one.
You don't lose much in terms of shell interop though - the native exec command understands a lot of the basics (file redirection, pipelining, background execution). In the simplest case, it's just one more word:
exec wget $URL
You do have simple exceptions too, which terminate by default unless you catch
them (unfortunately, the stack traces aren't really useful). AFAIK exec throws
on a non-zero exit, and you can use it in your own code too: # Dead
error "IO error"
# Not dead
if {catch [error "IO error"] error_or_result} {
# The error
puts "Caught: $error_or_result"
} else {
# The result
puts "OK: $error_or_result"
}
I just wanna write a few small lines of a shell script which downloads stuff;
It is very very stupid through what loops you hvae to jump to do this with curl and bash script in a good way including readability and error handling.
Is a perl script really better?
Perl 5,6 and 7 did not make it very sane to me, managing and installing and working with perl is also less trivial then having a shell like bash, sh or dash available to you.
Something inbetween bash and go is missing, i like the approach of crush. I think thats the biggest misstake happening in bash: playing around with strings and auto expansion and substition etc. Its weird, its error prone, it doesn't have a proper clean well defined ecosysem.