5 ms·
perl is still the most practical way to mitigate shell script abominations like that. Though tcl's a good option too.
by shawn_w 2y ago
perl is still the most practical way to mitigate shell script abominations like that. Though tcl's a good option too.
- nextos 2y agoOr Ruby, which is essentially Smalltalk for Unix, plus lots of Perl-isms. Haskell (e.g. shh) and Clojure (Babashka) are also a nice for this usecase, but more niche options.
- chubot 2y agoOils aims to be the absolute best way to migrate shell scripts! (I created the project, and the wiki page being discussed) https://www.oilshell.org/ https://www.oilshell.org/ OSH is the most bash-compatible shell in the world, and YSH is a new language ls | sort | uniq | wc -l # this is both OSH and YSH var mydict = {foo: 42, bar: ['a', 'b']} # this is new YSH stuff you can start using json write (mydict) The difference between OSH and YSH is exactly a set of "shopt" options [1], although YSH feels like a brand new language too! There is a smooth blend. I think it's worth it for 2 things alone - YSH checks all errors - you never lose an exit code - YSH has real arrays and doesn't mangle your variables with word splitting There's a lot more: modules with namespaces (use mymodule.ysh), buffered I/O that's not slow, etc. Gradually upgrading -https://github.com/oils-for-unix/oils/wiki/Gradually-Upgrading-Shell-to-YSH https://github.com/oils-for-unix/oils/wiki/Gradually-Upgradi... (people are writing new YSH, but not many people have gradually upgraded, so I'd definitely appreciate feedback from people with a big "shell script problem") --- There is a FAQ here about Perl: Are you reinventing Perl? - https://www.oilshell.org/blog/2021/01/why-a-new-shell.html#are-you-reinventing-perl https://www.oilshell.org/blog/2021/01/why-a-new-shell.html#a... Not to say that migrating to Perl is worse in any way, i.e. if you already know Perl or your team knows it. But objectively YSH is also a shell, so I think more of the code carries over, and there is a more direct upgrade path. --- [1] Unix Shell Should Evolve like Perl 5 - https://www.oilshell.org/blog/2020/07/blog-roadmap.html#the-unix-shell-should-evolve-like-perl-5 https://www.oilshell.org/blog/2020/07/blog-roadmap.html#the-... - i.e. with compatible upgrade options
- RestartKernel 2y agoThat looks great! I moved from Fish and NuShell to Zsh because of its reasonable compatibility with bash, so OSH seems right up my alley.