4 ms·
I have wondered if there could be a CoffeeScript or TypeScript of Bash. Basically a transpiler to Bash that is safer and more convenient to write in. Then you
by agentgt 10y ago
I have wondered if there could be a CoffeeScript or TypeScript of Bash. Basically a transpiler to Bash that is safer and more convenient to write in.
Then you just ship the bash script with no dependencies. The transpiler might even be smart enough to take GNU/BSD differences into account.... ahh another project idea that I do not have time to implement :(
EDIT: Apparently there is one and it is even the language I would have problem implemented the compiler in (OCaml) [1] . It is shame though it doesn't seem to have much functionality other than checking if files exist and string manipulation. If they had just focused exclusively on Bash/coreutils (and Powershell for windows) they could probably add a lot more features.... Windows seems to be holding them back.
[1]: https://github.com/BYVoid/Batsh https://github.com/BYVoid/Batsh
- morenoh149 10y agoI too have looked for this in the past. Found https://github.com/mweststrate/nscript https://github.com/mweststrate/nscript js -> bash
- boardwaalk 10y agoIt seems to me there's little reason to not just use another shell or scripting language (Python? Ruby? TCL?) You're not constrained by the browser only supporting JavaScript here.
- nine_k 10y agoAbility not to install a dependency (especially something relatively sprawling, like Ruby) may be the whole point. Some even constrain the scripts to sh, so that even bash isn't a dependency and you can run on e.g. OpenWRT.
- scrollaway 10y agoI remember Batsh from when it was on Show HN. 3k+ stars and no releases since September 2014 :( Real shame, something like this is incredibly useful.
- efferifick 10y agoThere is also m4sh which are just M4 macros that compile to portable bash scripts. Albeit it is not convenient to write in, and probably harder to avoid making mistakes. [0] https://www.gnu.org/software/autoconf/manual/autoconf-2.62/html_node/Programming-in-M4sh.html https://www.gnu.org/software/autoconf/manual/autoconf-2.62/h...