4 ms·
"sh" [1] by amoffat did something similar to this in python. It's so marvelous I've also ported the same ideas to "gosh" [2] for use in golang and "josh" [3] f
by heavenlyhash 12y ago
"sh" [1] by amoffat did something similar to this in python. It's so marvelous I've also ported the same ideas to "gosh" [2] for use in golang and "josh" [3] for use in java. There's probably others as well -- I'd love to hear about more options in other languages.
[1] https://github.com/amoffat/sh/ https://github.com/amoffat/sh/
[2] https://github.com/polydawn/pogo/blob/master/gosh-demo.go https://github.com/polydawn/pogo/blob/master/gosh-demo.go
[3] https://github.com/polydawn/josh/ https://github.com/polydawn/josh/
(The golang implementation is probably my favorite of these, since pipelining the output is by far the most pleasant experience there, and channels actually provide parallelism in a similar way what one expects from unix pipes. I'll admit I haven't benchmarked, but I suspect pipelining a lot of information in the python one is going to encounter the GIL; and as for the java one, well, let's just say I'd like to have a word with the authors of the current java subprocess invocation APIs.)
- jeremycw 12y agoShellJS [1] for Javascript [1] https://github.com/arturadib/shelljs https://github.com/arturadib/shelljs
- simcop2387 12y agoThe grandaddy of all of those is probably the http://perldoc.perl.org/Shell.html http://perldoc.perl.org/Shell.html module in Perl. The idea is really nice for a lot small scripts but can seem to hide some magic because you're treating commands as functions.
- kjs3 12y agoI can't imagine why you'd think that. SCSH predates Perl Shell (1993 v. 1994?), and things like CLASH are almost as old. GNU Emacs has been usable for a login shell for almost that long, as I recall.
- simcop2387 12y agoI meant the modules that were talked about in the parent comment. Not as a predecessor to scsh. The Perl module I referenced isn't to use Perl as a shell and neither are the modules mentioned by heavenlyhash. They instead allow one to use system commands as if they were previously declared functions. While scsh and clash both do this to allow you to use it as an interactive shell they do not extend the parent language (as far as I can see) to be used like a shell scripting replacement. Emacs is a slightly different case as im not sure where the line between elisp and emacs should be drawn. If yiliu look at the modules in the other comments you'll see they all have roughly the same interface as the Perl module from 1994, before many of the languages, python, go, java existed or were really used by then.
- kjs3 12y agoIf "allow one to use system commands as if they were previously declared functions" is your criteria, then things like Symbolics Genera, PERQ POS and Xerox Star/Alto predate it by even more. This is not a new or original idea to Perl.
- saidajigumi 12y agoFantastic and new to me, thanks. I love amoffat's approach to creating a Python DSL for command-line app interaction.