12 ms·
As a note, there have been strongly-typed shell languages for Unix for some time. Scheme Shell[0], Turtle[1] and TCSH[2] leap to mind; but there's nothing preve
by dleslie 10y ago
As a note, there have been strongly-typed shell languages for Unix for some time. Scheme Shell[0], Turtle[1] and TCSH[2] leap to mind; but there's nothing preventing a developer from using Perl, Python, Lisp or any other language that allows itself to accept stdin as an interpreted script.
0: https://scsh.net/ https://scsh.net/
1: http://www.haskellforall.com/2015/01/use-haskell-for-shell-scripting.html http://www.haskellforall.com/2015/01/use-haskell-for-shell-s...
2: http://www.tcsh.org/Welcome http://www.tcsh.org/Welcome
Edit: oh my, I posted the wrong link for tcsh. No one noticed, but my apologies nonetheless.
- codemac 10y agoI want to throw my support behind scsh! It's useful for those things that cross the boundaries between a program, and a shell script. I've found once you need functions for a shell program, it's time to step up to scsh. I also wish scsh ports were more well maintained so people could use their favorite schemes with scsh syntax, but it's quite a large codebase to port, so remember that it's scheme48 scheme.
- patrickmay 10y agoI thought I was the last person using scsh! Now if I could just imbue my coworkers with your good taste....
- codemac 10y agoNice! :) I write a lot of my stuff in guile when it's more formalized, but scsh's run syntax is just the bees knees. Can't get rid of it.
- qwertyuiop924 10y agobits of SCSH have been ported to every scheme out there now. And some have been improved. Irregex, in particular, is a dramatically improved version of the SCSH regex engine.
- codemac 10y agoOh yes, ashinn's irregex is so good, I just include it in my home directory.
- astrodust 10y agoThis is why I find PowerShell to be an answer to a question nobody asked. If bash/zsh isn't cutting it for you, drop into something like Python, Ruby or Perl to do the heavy lifting. PowerShell will never accumulate a library as comprehensive as what any of those three have, each has had decades to accumulate packages of all kinds, and more are still being added. It's odd, but not surprising given their history of "Not Invented Here", that Microsoft never even considered using Python or Ruby when they both have .Net implementations. Their enthusiasm for JavaScript wasn't sufficient for them to embrace that either.
- xl 10y ago[Disclaimer: I work for Microsoft.] As far as I recall, the original impetus behind what became PowerShell (as handed down to us in a conference room by Ballmer himself, sometime around 2001) was to fill the gap between ops people who did enterprise administration manually with tools like MMC and engineers who automated enterprise administration with tools like C++/DCOM. The latter were necessary in a lot of cases, but they were expensive, and we needed to give the industry a way to do powerful automation without hiring a bunch of PhDs. So, yes, someone did ask for it - the IT industry.
- itomato 10y agoNot "The IT Industry", surely only a subset of Windows systems managers.
- jaredhansen 10y agoThat's actually a pretty substantial chunk of "the IT Industry" though. And if you're the people who make Windows, it's not surprising that it's a big enough chunk to do something about.
- jl6 10y agoI personally find that the term "IT" has become a bit of a code word for "Enterprise Wintel", and that anyone working outside of the gravitational pull of Microsoft prefers to describe themselves as working in "tech"
- deegles 10y agoI've been loving using Node.js for scripts. You get all the NPM goodies plus STDIO, and they end up working just as well as shell scripts. One of the big advantages IMO is that I only need to master one language for all of my needs, from browser to server to shell :)
- ryanbrunner 10y agoHow do you find dealing with async? Virtually everything I'd want to do with scripting would almost certainly be async in node libraries, and while I'm willing to pay the callback / promise tax in production code, for scripts it seems like the convenience of just dealing with everything synchronously would outweigh the advantage of keeping things in one language.
- deegles 10y agoIn scripts I'll keep things synchronous unless I have a specific need for async.
- jaegerpicker 10y agoPersonally for me I use es2015 and async/await in shell scripts since it's so close to writing sync code to me. I have an alias to my global babel so it's uber easy to transpile and run the code. I right a lot of node code for work so it's just native to me but I'd recommend others look into it. NPM is such an amazing ecosystem for it.
- tracker1 10y agoI tend to favor es2015 + async/await (via babel-node). Combined with bits from shelljs and mz packages, it all comes together pretty well.
- Senji 10y agoPure madness. I'm sure this is how elated the architects of the Tower of Babbel felt about themselves right before the crash.
- svieira 10y agoThere is also Ammonite Shell[0], XONSH[1] 0: http://www.lihaoyi.com/Ammonite/#Ammonite-Shell http://www.lihaoyi.com/Ammonite/#Ammonite-Shell 1: http://xon.sh/ http://xon.sh/
- klibertp 10y ago0: scsh is a nice scripting language, however it's not meant for interactive usage (PowerShell is) See: http://www.alphanet.ch/~schinz/scsh-faq/scsh-faq_4.html#SEC33 http://www.alphanet.ch/~schinz/scsh-faq/scsh-faq_4.html#SEC3... Scheme is also dynamically typed. 1: It's the first time I see it, but from a cursory glance and some docs (http://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-Prelude.html http://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-...) I think it doesn't include simply calling external commands (I couldn't find any info on how to wrap an external executable with type, too). Without this, it can't be a real "shell", only a scripting DSL for Haskell. It's not very good for interactive use as it relies on ghci. 2: tcsh is meant for interactive use and is a shell; I used it when working with FreeBSD but never wrote any scripts in it. However, I don't see any mention of types in it's manual (other than file types): http://linux.die.net/man/1/tcsh http://linux.die.net/man/1/tcsh PowerShell is statically typed like Turtle, has a nice scripting language like scsh and is meant for interactive use. It's not only typed, but also (partly) object oriented and with full and direct access to all .NET/Mono classes. That also implies that you can write commands in any of the CLR-targeting languages, by the way, like F# or Clojure-CLR. PowerShell is unique (not literally so, as I'm sure there are other projects doing similar things, but I think it's safe to say that it's unique among widely used shells) in what it provides and in that it takes all that into interactive use. It's definitely worth checking out if you haven't already. Of course, keep in mind its problems, like the mentioned smaller number of already available utilities.
- codygman 10y ago> I think it doesn't include simply calling external commands proc and inshell. Did you check out the built-in tutorial? http://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-Tutorial.html http://hackage.haskell.org/package/turtle-1.0.0/docs/Turtle-...
- iso-8859-1 10y agoYou're linking to an old version. Here is the current version: http://hackage.haskell.org/package/turtle/docs/Turtle-Tutorial.html http://hackage.haskell.org/package/turtle/docs/Turtle-Tutori...
- Volt 10y agoI've never seen tcsh referred to as strongly typed. Could you elaborate?
- dleslie 10y agoI was mistaken, it's not. ~> @ i = 0 + "foo" @: Expression Syntax. ~> @ i = 0 + "1" ~> echo $i 1
- i_feel_great 10y agoThere is also GNU Guile, with a fantastically easy to use FFI. Has a great manual too.
- tracker1 10y agoI agree... though my default reach-for these days tends to be node. I don't much care for ps, even if it's now available on Linux, I just don't see myself using it much... I like C# a lot, and even other .Net languages. But I don't like all the extra typing for one-off scripts, even if they do get re-used. I can paste various commands for other terminals/environments in a tweet, the same can't always be said for ps. It's just a lot of typing.