23 ms·
Hush, a modern shell scripting language
- spb 5y agoThis looks excellent - I outlined wanting something like a cross between Lua and Bash back in 2016, and at first glance, it would seem that this project by and large fits the bill: https://github.com/stuartpb/lash https://github.com/stuartpb/lash
- voat 5y ago
- xx__yy 5y agoInteresting language/script. Are there any other comparable alternatives? Would Node/TS-Node be a suitable replacement with a few shell helper functions?
- _aerolith_ 5y agoI'm partial to zx for that (it has optional typescript support) and pretty reasonable ergonomics
- velcrovan 5y agoA recent one is Zuo, a tiny Racket for scripting/makefiles: https://docs.racket-lang.org/zuo/index.html https://docs.racket-lang.org/zuo/index.html
- vaporup 5y agohttps://www.abs-lang.org https://www.abs-lang.org
- RickHull 5y agohttps://www.oilshell.org/ https://www.oilshell.org/
- chaorace 5y agoIs this really a shell scriping language? Hush isn't an interactive shell, nor does it compile to a common shell script. The only way to run these scripts is to install the hush interpreter and run the script through it. Isn't that just a normal scripting language? What's the real benefit of using this over Node or Python? I suppose the syntax is more aesthetically similar to shell scripts... but I don't exactly see that as a plus.
- da39a3ee 5y agoThe point is that you can do things like create external processes, pipe them together, redirect output to files, with the same ultra-lightweight syntax of bash etc. Compare that to all the nonsense you have to do in Node or Python to pipe two processes together!
- gorgoiler 5y agoYou’re right in that writing Python using shell paradigms is awful. Writing Python that shells out to do stuff — but using Python paradigms — isn’t so bad. Particularly if you are used to calving off your shell stuff into shell functions that run something and massage the output. In Python you end up doing something pretty similar: yield the text you want and use that as arguments to the next call to subprocess.run. Basically “| xargs command” but nicer.
- feanaro 5y agoThis is a thing: https://pypi.org/project/plumbum/ https://pypi.org/project/plumbum/
- da39a3ee 5y agoThis looks nice. I'm slightly surprised by the error handling though: if std.type() == "error" then It seems (a) a bit verbose and (b) a bit hacky to compare the type against the string "error". I wonder if more ergonomic error handling is something the author is planning.
- JNRowe 5y agoThe section on the try operator¹ includes an example showing the syntactic sugar to reduce the verbosity. It does feel like it might be better to introduce it earlier on, as I was feeling the same way as you until I saw that. ¹ https://hush-shell.github.io/error-handling.html#try-operator https://hush-shell.github.io/error-handling.html#try-operato...
- hajile 5y agoDestructuring and a little bit of pattern matching could go a long way here.
- dahfizz 5y agoReally cool concept. I like the idea of scripting in a "safe" language and then dropping into a command block to do all the system level stuff. It's the best of bash and python, in a way. I'm not sure when I would use something like this. The verbosity definitely means I wouldn't use it as my actual shell, and I don't think that is the intention. Maybe something like a big service / orchestration script where I need to do all sorts of file manipulation, command processing, etc but there's enough logic and complexity to make it annoying to do in bash.
- DiabloD3 5y agoThe unfortunate truth of all such projects: if it isn't pre-installed on all reasonably complete Linux distos, it can truly succeed, no matter how awesome and cool it is... ... which is why I try to write as much stuff as POSIX sh as possible, and sometimes I have to throw in a Bashism to get by. And I say this as someone that wishes sh was better, semi-lovingly.
- caymanjim 5y agoIt wasn't that long ago that a fresh Unix install of any flavor didn't come with Perl, Python, zsh, or other common shell or scripting languages. And there's already a trend away from installing those by default. Since adding them now takes mere seconds, the barrier is low.
- tptacek 5y agoThis isn't really true at all. We have an ungodly amount of operational process and knowledge tied up in bash scripts deployed across our fleet, but we could easily deploy a different shell, and use that. We don't use bash because it's the least common denominator on our systems --- in fact, I think in an era of AMIs and Dockerfiles, few people do. We use it because of path dependance.
- 1500100900 5y agoThis is easy to say when you don't have to comply to some industry standards.
- tptacek 5y agoI don't know what this is supposed to mean.
- JNRowe 5y agoI think part of the problem is that we still don't have a standard /bin/sh even though there is a written standard. It feels fair to me to suggest that you can call dash the working standard on Linux, but you can't trust that beyond Linux systems(and I'm ignoring installs that are busybox-based here too). And that also feels like the problem with extending a script with a few bashisms too, as you're suddenly trying to remember when that feature appeared. Off the top of my head I'm wondering what things won't be available to Mac users because it ships with a pre-GPLv3 bash for example.
- JNRowe 5y agoThe language looks really quite interesting. I could see myself using it for quick scripts. I think I'd prefer bash's noclobber behaviour to be the default redirection style. The explicitness of being forced to >| always feels like a nice safety feature to me, which would tie in nicely with their other defaults for safer scripting. Also, not sure I'm keen on their minor change to the redirection syntax¹. It suggests that "2>1" and "2> 1" have very different results, which feels like an odd change to make when you're keeping the other aspects of that syntax. Probably says more about me though, I want 100% match or a complete break to force me to think. I think it is interesting to compare the approach of oil², which has overlapping goals but is attacking the problem of improving shell scripting while attempting to keep the syntax. ¹ https://hush-shell.github.io/cmd/basic.html https://hush-shell.github.io/cmd/basic.html ² https://www.oilshell.org/ https://www.oilshell.org/ (note: if - like me - you're not seeing syntax highlighting for hush then enable JS)
- nine_k 5y agoFrankly, I think that only, say, three things are worth keeping from traditional shells: pipes, redirections, and $-variables. Most of the rest in them are design choices dictated by highly constrained machine resources and, most of all, incremental evolution. I'd say that Bash as a language is larger than Hush, while being conceptually much less clean, and in many regards less ergonomic.
- pxeger1 5y ago> It suggests that "2>1" and "2> 1" have very different results FYI, "2>1" and "2 >1" already have very different results in Bourne shell. So I don't think it's an unforgivable sin.
- chubot 5y agoYeah this is the crazy thing about shell redirect syntax 2>&1 # descriptor redirect 2>& 1 # identical to above 2 >&1 # runs a command "2" and then does a descriptor redirect And likewise for 2>1 2> 1 2 >1 The 2 is really part of the operator, but the 1 isn't !
- 5y ago
- andrewmcwatters 5y agoI've changed my mind about this sort of thing recently. I disagree with the widespread belief that one should part with shell scripts as soon as possible. Yeah, there are definitely eventually scripts where one should rewrite the work in another language, but we now just have too many people who have no idea what getopts is, too many people who think bash is available everywhere, too many people who think it's a good and safe idea to put all of your program arguments in environment variables, too many people who have no idea where POSIX specifications are and why they're useful, too many people who don't know how to simply reach for manual pages and do all their learning exclusively off Stack Overflow and Medium, etc. You don't need advanced knowledge of all of this stuff, but when you're outright afraid of it, there's a professional problem involved. I'm not asking for people to have a comprehensive knowledge of awk, but if you've avoided every opportunity to simply understand what 'set -e' 'if' and 'test'/[]' are, you're intentionally atrophying your professional development.
- klabb3 5y agoThe reality is that blame shaming devs for not learning something isn't effective. No matter your personal beliefs, nobody is getting fired for not knowing the intricacies of sed or bash or awk. The only options are keeping archaic artifacts around and have the elders maintain it, or improve it for everyone. I have tremendous respect for our unix/posix legacy but at the same time they didn't get everything right. How could they? That said, it's harder to build consensus today. Currently people are replacing shell scripts with all kinds of stuff, and that's not good either. We need something good enough and ubiquitous, imo.
- smackeyacky 5y agoI am a greybeard, old school kinda unix guy, but at some point insisting everybody learn latin to understand the scriptures is just not going to work. As long as Powershell dies I'm more than happy to agree that any bash script that exceeds 24 lines should probably be written in something newer.
- majkinetor 5y agoWeird bigotry.
- jordemort 5y agoThis looks neat. The command blocks are an interesting solution to the question of how to impose more structure on things without imposing a lot of additional syntax where it isn't wanted.
- deleted 5y ago[deleted]
- ACAVJW4H 5y agohttps://xon.sh/ https://xon.sh/ has an impressive approach merging python and shell
- ogogmad 5y agoFor access to libraries, and familiarity to programmers, this is probably the best shell replacement.
- SPBS 5y agoNote to author: the part with actual shell examples is buried too deep, I didn't think it was capable of actual shell things (seemed more like a scripting language) until I came across the 'Shell Capabilities' chapter. Seems like an obvious title but I completely glossed over it while perusing until I did a keyword search for 'redirection', and I imagine many people will too. Consider putting everything on a single page like oil shell does [http://www.oilshell.org/release/latest/doc/oil-language-tour.html http://www.oilshell.org/release/latest/doc/oil-language-tour...], so that simply scrolling down will show the shell examples without having to manually click click click the next button.
- ibizaman 5y agoI agree. As a language which intends to replace shell scripts, I would show first that the syntax is pretty much the same in Hush. I would put this page first https://hush-shell.github.io/cmd/index.html https://hush-shell.github.io/cmd/index.html
- jbverschoor 5y agoYup. Most shell scripts simply execute commands, handle files. It should begin with more examples using find, grep, sed, and a for loop.
- alpaca128 5y agoTo add to this, an example using pipes would be great too. I assume it's done the normal Bash way within command blocks. But I have no idea whether it's supported, after all the point is to use a different, more maintainable language. But otherwise I think it's great, it has all the basics I'd expect from a modern language and still seems simple enough for quick scripts. I'll try it alone for the better syntax and the imho neat idea to return stdout & stderr separately in a dict.
- heavyset_go 5y agoI like the idea of shell blocks. Looks like you can get something similar in Rust with cmd_lib[1]. [1] https://github.com/rust-shell-script/rust_cmd_lib https://github.com/rust-shell-script/rust_cmd_lib
- transfire 5y agoSo you make dictionaries with `@[ ]` instead of the more usual `{ }` so you can use them for “bash” blocks? Nah. There’s surely a better way. Other than that, kudos on a clean syntax.
- deleted 5y ago[deleted]
- zestyping 5y agoThis seems worth a try; some interesting design choices here! Definitely put the shell scripting examples up front if you want to call it a shell scripting language. I had to click through ten pages before finding out how to execute a command. I wonder how usable it would be as an interactive shell with some conveniences. For example, the prompt could pre-type a "{ }" for you and put the cursor between them, so you can immediately enter commands, or decide to backspace over the "{" if you want to write more complex expressions.
- schoen 5y agoI wonder if the name of this language is a reference to Goodnight Moon. The language is inspired by Lua, and one of the occupants of the room in Goodnight Moon is > a quiet old lady who was whispering "hush"
- pjungwir 5y agoThis looks really cool! I think I found a few errors in the docs: 1. On https://hush-shell.github.io/intro/basic-constructs.html https://hush-shell.github.io/intro/basic-constructs.html you say that `let x = array[5]` should panic, but the array has enough items. Perhaps you wrote that, then added more items to the array and forgot to change it? 2. On https://hush-shell.github.io/error-handling.html https://hush-shell.github.io/error-handling.html you sometimes have safe_div_mod and sometimes safe_division.
- francislavoie 5y agoI've already opened a pull request for the latter https://github.com/hush-shell/hush-shell.github.io/pull/1 https://github.com/hush-shell/hush-shell.github.io/pull/1
- 411111111111111 5y agoWouldn't the value of the fifth index be executed there, which is false and would hence fail? Not sure either though > safe_div_mod and sometimes safe_division Aren't those different things? Save division wouldn't use mod by default, right? The function for save division is missing though, but it might just be a built-in
- charles_f 5y agoI'll make the mandatory hn comment since I have not seen it yet. A website introducing a new language should show said language on the first page. It's like introducing a car by saying - safe - can ride on 4 wheels - 2 car seats included - highway compatible And then keep pictures for page 6.
- 16bytes 5y agoYes, this is the first thing that struck me. I don't know why people invest so much time inventing new languages and then fail at the last mile. If the front page of a new lang site doesn't have language examples showing not just hello world but core differentiating use-cases, why should I bother?
- nine_k 5y agoFirst, this is a pretty nice language, which achieves much with very few, very general constructs. It's distinctly higher level than Bash, while using much fewer concepts. Here I applause. Its shell capabilities are also minimalist, but should be ergonomic enough to avoid nearly all of the ceremony that Python's `popen()` usually requires. OTOH I'm certain that prefixing all standard functions with `std` will get tiresome soon; I'd go with prefixing them with a `@` or `:` or another short special-case glyph. Also, the fact that `1 != 1.0` scratches me the wrong way; I'd rather have an integer be equal to a float when the float's fractional part is exactly zero. It does make mathematical sense, and is cheap to implement. In general, Hush looks like a great language for cases when writing Bash becomes tiresome, and you'd rather reach for Python, Ruby, or Perl, but know that each incurs its own pain when used as a shell language. Hush would also make a very nice embeddable language, much like Lua on which it is based.
- lamontcg 5y agoI may steal a few ideas from this for a small language I'm playing with. I'd really like to see more small languages like this for doing productive things with computers.
- richardfey 5y agoIt would be nice to allow something like Go's: import "std" _ Which would allow using functions like print directly.
- dooopy 5y agoPowerShell is really good. Like, amazingly good.
- xnorswap 5y agoYes, I find it odd how there's a massive blind spot when it comes to powershell. Proponents of strong typing everywhere in their programming languages are put off by a shell that dares pipe objects rather than having everything as strings. I get that Unix has a long tradition and it's hard to change, but powershell is genuinely a modern shell that while uncomfortably verbose without aliases is extremely powerful and feels modern.
- majkinetor 5y agoIt blows my mind too. Typical verbosity argument is nonsense - people should use aliases. With cross platform shell, first time we have some reason not to use them, to make script more portable. Besides, this verbosity is form of documentation - you really must consider that any bash script comes with invisible man that you usually must check even after years of usage. When you factor that in, even fully verbose PowerShell is joy. Most of Unix haters seem to bi bigots. I have never seen good argument against PowerShell, apart of that it could be faster for specific use cases.
- tgv 5y agoIt seems like the powershell occupies a different niche than sh/bash, etc. It seems more oriented towards manipulating system properties than sorting and grepping. At least, the examples are always about system objects and properties. I wouldn't even know how to integrate normal unix commands in the powershell. Things like this look pretty counter-intuitive: https://devblogs.microsoft.com/commandline/integrate-linux-commands-into-windows-with-powershell-and-the-windows-subsystem-for-linux/ https://devblogs.microsoft.com/commandline/integrate-linux-c...
- majkinetor 5y agoSorting and grepping in PowerShell are an every-day trivial thing. I even use it to as data analytics tool to query moderate amount of data because its just simpler then using anything else (given that ConvertFromTo-XML,Json,Csv etc. are integrated, standard, and don't require bunch of other tools like jq, miler etc.) and I can send it to anybody along with the data to reproduce it or tweak it without having to install anything or learn any new language. > At least, the examples are always about system objects and properties Not sure where you get that idea from. Third party examples are not important at all. Majority of usage has nothing to do with the system and its properties. Not sure why you mentioned that particular method of invoking WSL stuff. If anything, it shows how powerful PowerShell is.
- petre 5y agoIt looks well though and with modern syntax but we already have Lua, Tcl, Guile, Perl, Python, Ruby, Node/Deno, Racket etc.
- JimmyRuska 5y agoFor Lisp/Scheme fans, take a look at Rash as well https://rash-lang.org/ https://rash-lang.org/
- Tistron 5y agoI generally like this. One confusing thing is the ? operator, it seems to do opposite things inside and outside command blocks. And I think I spotted a small mistake in https://hush-shell.github.io/intro/control-flow.html https://hush-shell.github.io/intro/control-flow.html where it's written "May be omitted if finished is false." which should be "... is true".
- Siira 5y agoI took a quick look, and I like what I’ve seen. Adding some advanced examples to a cookbook section will be appreciated.
- stormbrew 5y ago> Traditional shell scripting languages are notoriously limited<snip> I feel like people looking to replace shells and shell languages need to really think deep and hard about this if it's something they believe. Shell scripts are really anything but limited, and in fact most replacements are more limited (either by design or by accident), often imposing awkward control flow on you or making things that should be simple much much more complicated. Error prone? Sure. Difficult to maintain? Yep, often. But when the thing you're doing is working with external processes and hooking them together into some kind of routine, the reason shell scripts have endured is precisely because they are extremely good at that, and provide immense amounts of flexibility and power to how you go about it in a concise way.
- hnlmorg 5y agoI couldn't agree with this statement more. As someone who has developed their own shell over the last decade I've been keeping a close eye on what other people have been building too. So often I see people writing shells that are inspired by programming languages so their syntax looks amazing in documents. But they always strike me as being hugely tedious for repetitive and often quite dull tasks. The kind of 5 minute jobs that you drop into an interactive REPL to solve an immediate problem. And then maybe save as a shell script later if you find you're doing that task frequently. People look at the problems with error handling and maintainability (which, as you highlighted yourself, are very real) but they end up throwing the baby out with the bath water when trying to solve those problems. Ultimately it doesn't matter how well a shell is for scripting if it still creates more trouble as an interactive shell compared to (for example) Bash. I say that because we already have Python, Ruby, Perl, node.js, Jua, and a plethora of other languages that can be used for scripting. We don't need more scripting languages. We need better shells.
- klibertp 5y ago> We need better shells. Obviously. I don't think this is the most important missing part, though. I would say it differently: we need way, way better REPLs. IPython is an example of a REPL that's passable as a shell. It can run in a terminal and has a GUI version based on Qt, which allows displaying images inline. You can drop into a "real" shell with a single `!` character (you get pipes, output capture, and (Python) variable interpolation), and it even has some syntactic shortcuts for the parts where Python's own syntax is irritatingly verbose. If you like Python, then IPython can be your day-to-day shell right now. You just need to remember not to start ncurses programs from within qtconsole (works ok in terminal). I used it for a few years when I was forced to work on Windows. Before my time, I heard it was popular to use tclsh as a shell on Windows. I think that it proves that almost any language can be used as a shell, as long as its REPL is as rich and featureful enough. Since you can use Python as a shell, which as a language is not exactly the epitome of terseness and expressiveness, you could definitely make do with almost any other interpreted language, too. The problem is that very, very few languages have REPLs that are anywhere near IPython. It's so bad sometimes that you're advised to use `rlwrap` just to get basic line editing and history! I've been working on a new shell based on GNU Smalltalk[1]. I really like the syntax - or lack of thereof - and being able to dump an image (ie. full state of the VM) at any time (and load it later) seemed like a good idea. The only change I needed was to add the `|>` pseudo-operator, which puts what's on the left into parens. Being able to introspect the running session was my primary motivation: I wanted to make the shell and the whole environment as discoverable as possible. I wrote some code for that and then realized that the default REPL uses readline from C, so it freezes the entire VM when waiting for input (including all background threads). My workaround was to set up a socket server and connect to it via rlwrapped telnet... Anyway, I think "do we need a new shell" is the wrong question; instead, we should focus on improving REPLs to the point where a separate shell becomes unnecessary. [1] https://github.com/piotrklibert/stshell https://github.com/piotrklibert/stshell
- oefrha 5y agoReading the Capture section, it seems if you want to do a command substitution you’ll always capture both stdout and stderr. Which is a showstopper if stderr is used to print progress, interactive prompts, etc.
- dgan 5y agoWhat is a valid reason to add a "null" into a modern language? I thought it's a commonly established truth that it has been a mistake
- mpartel 5y agoThis is a dynamically typed language. Null makes sense there. It also makes sense in a statically typed language with union types, think `string | undefined` in TypeScript. The extra layer added by Some/None is not fundamentally necessary for safety.
- dale_glass 5y agoIf this wants to sell itself as a shell scripting language, it should very quickly advertise what is it that makes it superior to say, bash for typical shell scripting tasks. Shell scripts with bash are painful to the point that if I find myself writing more than around 10 lines of shell, I tend to stop and switch to Perl instead. But Perl hasn't been too popular lately and isn't ideal either, so I'm very much up for something better. Here's some features I want from a shell scripting language: * 100% reliable argument passing. That is, when I run `system("git", "clone", $url);` in Perl, I know with exact precision what arguments Git is going to get, and that no matter what weirdness $url contains, it'll be passed down as a single argument. Heck, make that mandatory. * 100% reliable file iteration. I want to do a "for each file in this directory" in a manner that doesn't ever run into trouble with spaces, newlines or unusual characters. * No length limits. If I'm processing 10K files, I don't want to run into the problem that the command line is too long. * Excellent path parsing. Such as filename, basename, canonicalization, finding the file extension and "find the relative path between A and B". * Good error handling and reporting * Easy capture of stdout and stderr, at the same time. Either together or individually, as needed. * Excellent process management. We're in 2022, FFS. We have 128 core CPUs. A modern shell scripting language should make it trivial to do something like: take these 50000 files, and feed them all through imagemagick, using every core available, while being able to report progress, record each failure, and abort the entire thing if needed. * Excellent error reporting. I don't want things failing with "Command failed, aborted". I want things to fail with "Command 'git checkout https:// https://....' exited with return code 3, and here's for good measure the stdout and stderr even if I redirected them somewhere". * Give me helpers for common situations. Eg, "Recurse through this directory, while ignoring .git and vim backup files". Read this file into an array, splitting by newline, in a single line of code. It's tiresome to implement that kind of thing in every script I write. At the very least it should be simple and comfortable. That's the kind of thing I care about for shell scripting. A better syntax is nice, but actually getting stuff done without having to work around gotchas and issues is what I'm looking for.
- danmur 5y agoOh my god, your first point. I had to pass arbitrary arguments through a couple layers of shell and I couldn't do it. Gave up and rewrote it all in Python, even though it's annoying in other ways, and I'm decent at shell scripting. It's a nightmare.
- t43562 5y agoFor me the reason for pursuing scripting languages over sh is because of multi-platform projects that I've had to support in the past where every little shell nuance, every tool nuance has introduced bugs in one platform or the other. It's too easy to create problems and too time consuming to find them. You need special resources to test/debug and so on. The installer and the build system were the areas that caused the most pain - e.g. trying to debug build errors because some system has a slightly different version of some tool like sed..... I felt that including a portable language in the installer would mostly eliminate this problem since one could eliminate the use of these hard-to-standardise tools. I don't care about POSIX standard command-line tools - IMO they are an example of how to encourage the proliferation of variants by blocking progress. Some installers include Java which is a nightmare - big and not helpful. IIRC InstallJammer included TCL which was not bad. I think GNU make (even though it is old school it's very commonly used) needs a shell that can work on windows AND UNIX operating systems equally and is fast to load up (i.e. not cygwin). The problem with e.g. using python as the make shell is that it has a bigger startup time than e.g. bash which is ok for most usecases but does matter in a build. So I sort of like the idea of hush but I need to find out how portable it is and what's the startup time.
- blacksqr 5y agoYou might love autosetup, a Tcl-based autoconf tool chain replacement. Not just Tcl-based, but designed to work with a simple Tcl subset shell called Jim, which compiles from one source code file. So you can bootstrap your project in a mostly-platform-independent way with a standard C compiler as the only prerequisite. https://msteveb.github.io/autosetup/ https://msteveb.github.io/autosetup/
- hussainbilal 5y agoWhy use types? Why not introduce built in parsers to provide validations instead? (i.e. https://github.com/antlr/grammars-v4 https://github.com/antlr/grammars-v4) I think hush is going in the wrong direction. The majority of shell automation is associated with running IaC and container images / orchestration tools. Shell scripts don't need to follow functional programming or OOP. They need to be container-oriented / VM-oriented / image-oriented with a conformation to YAML notation as this is already the adopted norm for containers and IaC.
- hussainbilal 5y agoSide note: The most straightforward way to incoporate YAML as an elevated text "type" would be to define a new type of pipeable file descriptor on all commands, specifically meant for replacing shell script options / flags. (That way options aren't mixed with stdin) Edit: and you get typing validation for free by running your yaml options through a yaml schema validator should you choose to do so
- bezospen15 5y agoPretty sure we don't need yet another scripting language
- ilyash 5y agoHi. Author of Next Generation Shell. I share the line of thought with Hush. But then we have arrived at different solutions. Small comparison here - https://www.reddit.com/r/ProgrammingLanguages/comments/ubwizf/comment/i68s5wg/?context=1 https://www.reddit.com/r/ProgrammingLanguages/comments/ubwiz... In my probably biased view, NGS is even more domain specific (handling of exit codes, syntax for running+parsing, etc) and more concise.
- mmargerum 5y agoGo compiles so quickly i use it for all of my scripting.
- rosencrantz 5y agoWasn't Hush already the name of the HUmbleSHell ( Hush is a Bourne/POSIX-style shell that was originally part of BusyBox ) ...https://github.com/sheumann/hush https://github.com/sheumann/hush
- pfheatwole 5y agoYes, and it lives on in a variety of minimalist environments under active development, such as: * U-boot: https://github.com/u-boot/u-boot/blob/master/common/cli_hush.c https://github.com/u-boot/u-boot/blob/master/common/cli_hush... * Busybox: https://github.com/brgl/busybox/blob/master/shell/hush.c https://github.com/brgl/busybox/blob/master/shell/hush.c * Barebox: https://github.com/barebox/barebox/blob/master/common/hush.c https://github.com/barebox/barebox/blob/master/common/hush.c
- TheCycoONE 5y agoA few things I commonly do in bash that it isn't clear (or wasn't immediately clear from the documentation that you can do in Hush): Pass environment variables into a single command ala `NO_COLOR=1 ./foo` in standard sh. The only workaround I see is std.export to set it, and then std.export again to unset it. The section on expansion doesn't mention std.glob - since there are times when you want to handle globs in variables it might be worth mentioning it there. Some equivalent to getopt for argument parsing
- ilaksh 5y agoI like this a lot. I just wish you could omit the 'std.' and use 'fn' instead of 'function'. How does one pipe a command block output into another?
- renox 5y ago> 1 == 1.0, # false, int and float are always distinct. Uh?? If int and floats are always distinct then you should disallow int and float comparison (panic) instead of allowing it and always returning false! That said it is probably a good idea to disable comparison for floats algother: maybe == would be int&bool&string only but for floats there would be ~= (approximate relative equality) but of course the issue is that not everybody will agree on the correct percentage tolerated for equality: 0.1%, less? And still in https://hush-shell.github.io/intro/basic-constructs.html https://hush-shell.github.io/intro/basic-constructs.html , the example ( # this would cause a panic: # let x = array[5] ) is probably wrong now: 5 is a valid index in the array..
- sophacles 5y agoThere's no interactive shell from what I can see. How does this qualify as shell scripting? The point of a shell is that it's how I interact with the system. The point of scripting that is to automate my interactions by storing the exact same commands I type and sometimes adding a bit of logic around them. Hush is not that.
- chubot 5y agoFWIW people are mentioning tons of alternative shells in this thread, and most of them are already listed here: https://github.com/oilshell/oil/wiki/Alternative-Shells https://github.com/oilshell/oil/wiki/Alternative-Shells (if not, feel free to add them)
- rml 5y agoFolks interested in this design space may enjoy reading about scsh (A Scheme Shell) From the scsh paper (https://web.archive.org/web/20081010222846/http://www.scsh.net/docu/scsh-paper/scsh-paper-Z-H-4.html https://web.archive.org/web/20081010222846/http://www.scsh.n...): > I have designed and implemented a Unix shell called scsh that is embedded inside Scheme. I had the following design goals and non-goals: > The general systems architecture of Unix is cooperating computational agents that are realised as processes running in separate, protected address spaces, communicating via byte streams. The point of a shell language is to act as the glue to connect up these computational agents. That is the goal of scsh. I resisted the temptation to delve into other programming models. Perhaps cooperating lightweight threads communicating through shared memory is a better way to live, but it is not Unix. The goal here was not to come up with a better systems architecture, but simply to provide a better way to drive Unix. {Note Agenda} > I wanted a programming language, not a command language, and I was unwilling to compromise the quality of the programming language to make it a better command language. I was not trying to replace use of the shell as an interactive command language. I was trying to provide a better alternative for writing shell scripts. So I did not focus on issues that might be important for a command language, such as job control, command history, or command-line editing. There are no write-only notational conveniences. I made no effort to hide the base Scheme syntax, even though an interactive user might find all the necessary parentheses irritating. (However, see section 12.) > I wanted the result to fit naturally within Scheme. For example, this ruled out complex non-standard control-flow paradigms, such as awk's or sed's.
- ilyash 5y agoPrepared a comparison to Next Generation Shell here: https://github.com/ngs-lang/ngs/wiki/Hush-vs-NGS https://github.com/ngs-lang/ngs/wiki/Hush-vs-NGS On one hand we are on it since 2013 so there is "more" but I would actually like to highlight the difference in OOP and functional approaches: types, inheritance, multiple dispatch.