Live data from Hacker News

Scsh – Scheme as a Unix shell

scsh.net

11–20 of 20 posts

Re: Scsh – Scheme as a Unix shell

#11

"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/ [2] https://github.com/polydawn/pogo/blob/master/gosh-demo.go [3] https://github.com/polydawn/josh/ (The golang impleme…

The grandaddy of all of those is probably the 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.

Re: Scsh – Scheme as a Unix shell

#12

I'd love to see something a bit less trivial, like iterating over the output of another command to run some other commands for i in `bin/hosts`; do ssh $i uptime; done

There might be a better way, but this should work:

    (for-each (lambda (x)
            (run (ssh ,x uptime)))
          (run/strings (cat /etc/hosts)))

Re: Scsh – Scheme as a Unix shell

#14
post #7

That example looked like it would be hell to write from the tip of the tounge.

Nah, it shouldn't be hard once you're used to (fun a b) syntax. So what would be pipe(cmd1(), cmd2()) in an algolic syntax is instead (pipe (cmd1) (cmd2)) and so on from there.

Re: Scsh – Scheme as a Unix shell

#15

"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/ [2] https://github.com/polydawn/pogo/blob/master/gosh-demo.go [3] https://github.com/polydawn/josh/ (The golang impleme…

Fantastic and new to me, thanks. I love amoffat's approach to creating a Python DSL for command-line app interaction.

Re: Scsh – Scheme as a Unix shell

#16

"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/ [2] https://github.com/polydawn/pogo/blob/master/gosh-demo.go [3] https://github.com/polydawn/josh/ (The golang impleme…

The grandaddy of all of those is probably the 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.

I 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.

Re: Scsh – Scheme as a Unix shell

#17
post #16

Earlier quoted context omitted.

The grandaddy of all of those is probably the 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.

I 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.

I 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.

Re: Scsh – Scheme as a Unix shell

#18

This is certainly an interesting use of Scheme macros for a shell-like DSL. For a long time I've mused over ideas for a Unix-ish shell that embeds first-class access to a richer scripting language than typical shell scripting. In this light, Scsh is similar to many other projects I've seen over the years in various languages, in that its effective aim is more about shell-like scripting in an alternate language. For m…

Emacs eshell. Amazing.

Re: Scsh – Scheme as a Unix shell

#19
post #16

Earlier quoted context omitted.

I 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.

I 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 languag…

If "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.

Re: Scsh – Scheme as a Unix shell

#20

I love sexprs. In fact, I generally prefer prefix notation with the extra parens. However, for such a high frequency interactive use case, it really does meet the cost/benefit requirements to have specialized syntax...

I'm quite familiar with Scheme and can do useful things with it. Not so sure how comfortable it would be to have Scheme on the command line.

Maybe it's just a matter of getting used to s-expr in that context, but after a few decades learning the classic command-line syntax, making that change could be hard.

OTOH the ability to use low level OS functions at the shell prompt or in a script might compensate for the trouble. Giving it a try would be the only way to find out. I might just do that and see what happens.

Post reply on HN