proj-plbook-plChShellLangs

Table of Contents for Programming Languages: a survey

Shell

Best practices and style guides:

Bash Shell

Best practices and style guides:

Tutorials:

Gotchas:

Best practices:

Frameworks:

Notes:

Powershell

https://msdn.microsoft.com/powershell

"abstracting gorp into high level task oriented abstractions, object pipelines, structured data, and the workflow from interactive shells to ad hoc scripts to formal scripts to production scripting." -- a powershell designer

Features:

Tutorials:

Retrospectives:

Opinions:

ls returns an array of objects, sort then sorts the array by each object’s DateTime? field (and here I’m asking it to sort in descending order with -d). The point is that sort isn’t depending on any text output, so it works with any array of objects regardless of the command that returned them. The other cool thing this enables is auto-complete awareness in the shell. If I typed: ls then the shell knows what makes sense in auto-completion here as ls has an actual return type and in this case it will give me a list of available fields that I can sort on. For those unfamiliar: ls and sort here are shortened aliases to more wordy verb-noun commands. These (as well as a large bunch of others) are given to you by default. " [10] " Yeah, PowerShell? is the only mainstream shell that behaves like the REPL environments from Xerox PARC workstations. Structured data with direct access to any OS API, regardless how it is provided, .NET, COM or straight C like DLL. UNIX world never had that, beyond trying to fit language repls as user shell, which on UNIX always feels like a leaky abstraction. " [11]
sort DateTime? -d
sort <Tab>

Scheme shell

Turtle shell (Haskell)

Zsh

Tcl

not exactly a shell language, but i'm putting it in this chapter

Opinions:

Tutorials:

Variants and implementations:

Links:

Fish shell

https://fishshell.com/

Opinions:

Oil shell

https://www.oilshell.org

https://news.ycombinator.com/item?id=24083931

http://www.oilshell.org/why.html

https://github.com/oilshell/oil/tree/master/doc

https://github.com/oilshell/oil/blob/master/doc/idioms.md

https://www.oilshell.org/blog/2019/10/04.html

http://www.oilshell.org/blog/2020/01/simplest-explanation.html

http://www.oilshell.org/preview/doc/syntactic-concepts.html

http://www.oilshell.org/preview/doc/syntax-feelings.html

" Command vs. Expression Mode

This is an essential syntactic concept. An Oil program starts in command mode, and commands are composed of words:

echo "hello $name" ls

wc -l

However there are several keywords and sigils that put you in expression mode, e.g. so that * means multiplication rather than glob:

var x = 1 + 2*3 + f(x) # After =, you're in expression mode

myfunc(42, 'foo') # Pretty-prints the result, without assigning

Inline calls also put you in expression mode:

echo $strfunc(1 + 2*3) # Between (), you're in expression mode echo @arrayfunc(x, y)

There are also expression substitutions with $[expr]:

echo "attr = $[obj.attr]" echo "key = $[d->key]" echo "item = $[array[1 + 2*3]]" " -- https://www.oilshell.org/blog/2019/10/04.html

" So the Oil language is just one part of the project, but it can also be broken down into many features! I drafted a blog post on Zulip to explain this, and I mentioned it in the long Nix RFC thread to give Nix users a sense of the project.

In the draft, I broke down the language into 5 major features, and gave an estimate of how done each one is:

    Python-like expressions on typed data: 9/10. This could be 7/10 or 8 /10 because we still need to divorce the expression evaluator from Python.
    Eggex (regular expression syntax): 9/10
    Procs: 6/10 (could be 7/10 after recent progress; we need to finish typed arguments)
    Ruby-like blocks for DSLs: 3/10. Need eval (myblock), etc.
    QTT (TSV-like tables): 3/10. We emit QTT in one place: pp proc, but we don't have a parser. The building block QSN is done!

This is still correct, although we should add more space for:

    Pure functions, and a unique form of coprocess: 2/10
    Shell builtins, which are like a "standard library": 4/10
        argparse for flag parsing
        describe for a test framework
        I also mentioned the Awk and and dplyr-inspired builtins in the last post.

" -- [24]

Nushell

http://www.jonathanturner.org/2019/08/introducing-nushell.html

https://dataswamp.org/~solene/2022-10-31-nushell.html

opinions:

Crush

https://github.com/liljencrantz/crush

"The author, Axel Liljencrantz, was also the initial developer of fish..." -- Robin Reala

elvish

uxy

Marcel

Xonsh

http://xon.sh/

Python-powered shell

Rash

Racket shell

tools to use other languages in shell pipelines

jc and jq

(not a shell, but a related idea)

"I believe a good fit for Unix commands is using a pipeline where the output of your command (say, ls) is converted to JSON, so that later in the pipeline you can use jq to filter / count / etc in a structured, non-whitespace-dependent way. A combination of jc (https://github.com/kellyjonbrazil/jc) and jq fits the bill for me:

    ls -l /usr/bin | jc --ls | jq '.[] | select(.size > 50000000)'" -- https://news.ycombinator.com/item?id=24080057

Babashka

(not a shell, but a related idea)

https://github.com/borkdude/babashka

mario

https://github.com/python-mario/mario

"Mario, for Python code in shell pipelines. Its most novel feature is (optional) async commands, so you can pipe in a list of urls, make many concurrent requests, and then process them in a single line.

    cat urls.txt | mario async-map 'await asks.get ! x.json()' apply len

" -- https://news.ycombinator.com/item?id=24079303

Closh

https://github.com/dundalek/closh

Oh

https://github.com/michaelmacinnis/oh https://www.youtube.com/watch?v=v1m-WEZz46U

See also Kernel

lash#Cat9 (Arcan shell)

https://arcan-fe.com/2022/10/15/whipping-up-a-new-shell-lashcat9/

Shell implementation

List of shell languages and projects