3 ms·
Can someone point out what is nice about this shell? I love higher order functions in general, and would love them in my shell, but have too much shell inertia
by mijoharas 11y ago
Can someone point out what is nice about this shell? I love higher order functions in general, and would love them in my shell, but have too much shell inertia to really consider switching at this point.
Could someone show some quick demonstrations of the possible power and/or elegance of this shell's syntax and functionality so I can appreciate what I'm missing out on?
EDIT: this is of course apart from the man page[0], which, while a lot nicer than most man-pages I've ever seen hasn't served to demonstrate the "big picture" ideas that are going to captivate me.
[0] https://wryun.github.io/es-shell/manpage.html https://wryun.github.io/es-shell/manpage.html
- vezzy-fnord 11y agoFrom the GH repo (raw b/c the syntax highlighting is messed up, damned Linguist): https://raw.githubusercontent.com/wryun/es-shell/master/examples/cdpath.es https://raw.githubusercontent.com/wryun/es-shell/master/exam... It's nothing special, it's just one of the earlier examples of a "better than Bourne or C" Unix shell, alongside Plan 9's rc. I believe es made it into Inferno, but I'm not sure. It's over 22 years at this point, though. In an alternate world, it might have made people more accepting of shell as a serious language.
- mcguire 11y agoIt is a much nicer programming language than its predecessors. From the paper[1]: "While rc was an experiment in adding modern syntax to Bourne shell semantics, es is an exploration of new semantics combined with rc-influenced syntax: es has lexically scoped variables, first-class functions, and an exception mechanism, which are concepts borrowed from modern programming languages such as Scheme and ML. "In es, almost all standard shell constructs (e.g., pipes and redirection) are translated into a uniform representation: function calls. The primitive functions which implement those constructs can be manipulated the same way as all other functions: invoked, replaced, or passed as arguments to other functions. The ability to replace primitive functions in es is key to its extensibility; for example, a user can override the definition of pipes to cause remote execution, or the path-searching machinery to implement a path look-up cache. "At a superficial level, es looks like most UNIX shells. The syntax for pipes, redirection, background jobs, etc., is unchanged from the Bourne shell. Es's programming constructs are new, but reminiscent of rc and Tcl. [Tcl was the new hotness at the time. --mcguire]" One example from there: es> fn echo-nl head tail { if {!~ $#head 0} { echo $head echo-nl $tail } } es> echo-nl a b c a b c Add the following definition: fn trace functions { for (func = $functions) let (old = $(fn-$func)) fn $func args { echo calling $func $args $old $args } } And you can get: es> trace echo-nl es> echo-nl a b c calling echo-nl a b c a calling echo-nl b c b calling echo-nl c c calling echo-nl Some additional features are exceptions and unwind-protect, automatic settor functions, and complex function return values. [1] http://wryun.github.io/es-shell/paper.html http://wryun.github.io/es-shell/paper.html