Live data from Hacker News

The Bash Hackers Wiki

wiki.bash-hackers.org

31–40 of 89 posts

Re: The Bash Hackers Wiki

#31

It seems like there is potential for making bash faster. 1. JIT compilation, caching and invalidating on updated source files 3. Rearchitecting similar a-la busybox all of coreutils, sharutils, grep, awk and sed as internal components to avoid forking as much as possible. Tool symlinks back to itself for compatibility. 4. Rearchitecting to simulate sub-shells with threads and local contexts, rather than globals/singu…

Regarding 4. it's an interesting point, and this actually exists, few people know that ksh93 (which was a big inspiration for bash and zsh) does not fork when it doesn't really need to, for instance if you strace the following:

echo $(echo $(echo echo))

Due to those command substitutions, on zsh/bash/mksh/dash/yash/busybox/osh you'll see 2 forks/clones, but on ksh93 there will be none, and this allows ksh93 to be insanely fast on "pure" shell scripts that have little use of external binaries and pipes, even faster than dash which is usually known to outperform most shells.

Re: The Bash Hackers Wiki

#32

Earlier quoted context omitted.

Having watched people hack together utterly bizarre bash scripts with awk and grep to handle json responses I'd very much agree here. And before someone raises jq, what % of servers already have python installed vs jq?

> And before someone raises jq, what % of servers already have python installed vs jq? How many of those servers have something like requests installed out of the box vs needing to fetch it via a package manager or PyPI? jq is available in Ubuntu's universe repository along with requests.

it's python, requests is one of it's many libraries for the purpose, would actually be quite concerned hiring someone who doesn't know the multiple stdlib solutions for this and still claims ability in python.

import json

import urllib.request

tough hey

Re: The Bash Hackers Wiki

#33

Earlier quoted context omitted.

> And before someone raises jq, what % of servers already have python installed vs jq? How many of those servers have something like requests installed out of the box vs needing to fetch it via a package manager or PyPI? jq is available in Ubuntu's universe repository along with requests.

it's python, requests is one of it's many libraries for the purpose, would actually be quite concerned hiring someone who doesn't know the multiple stdlib solutions for this and still claims ability in python. import json import urllib.request tough hey

I'd be as concerned with someone not opting to use what the documentation recommends[1] in lieu of the stdlib, as I would someone who puts together an awkward Bash script to parse JSON instead of just installing the 50kb package for jq.

> The Requests package is recommended for a higher-level HTTP client interface.

[1] https://docs.python.org/3/library/urllib.request.html

Re: The Bash Hackers Wiki

#34
post #7

https://xkcd.com/927 Is there room for a lightweight scriptable language that takes the place of, say, bash/zsh/korn/fish shell scripts? Please don't say perl/python or sed/awk.

Lua. Very small runtime, fast, powerful.

Re: The Bash Hackers Wiki

#35
Clicking around, I am glad to see portability to non-bash shells covered in some topics, despite the name of the site.

It seems to me like sometime in the last 10-15 years, what we used to call "shell scripting" became "bash" in popular discourse. I myself learned to write shell scripts in times and places where bash was the most popular default, but I never thought of it as writing intentional bashisms, but a set of skills applicable to multiple possible implementations, so I find that shift in jargon a little disappointing or incorrect.

Re: The Bash Hackers Wiki

#36

Earlier quoted context omitted.

The nice thing about Bash which can obviously not be said about Python is that Bash scripts will keep working (assuming whatever they call is also there of course) since Bash goes out of its way to preserve backwards compatibility. Considering its legacy, Bash can run scripts more than a decade before Python even existed. The only other scripting language i know of that has similar backwards compatibility is Tcl. Per…

I guess it's the trade off between backwards compatibility and readability/correctness/maintainability. Both languages will have technical debt overtime. In my opinion, I would much rather have to rarely update python scripts in exchange to for peace of mind that I can fix/update the script as need be. In my experience, *sh scripts can be fragile and hard to ensure correctness.

Having migrated something recently from python2 to python3, I'll take bash. I actually ported two of the three scripts to bash, and the third one I reluctantly moved to python3 (I needed python-pil). String handling in python3 in my opinion is a tire fire compared to bash.

Re: The Bash Hackers Wiki

#37
post #34
post #7

https://xkcd.com/927 Is there room for a lightweight scriptable language that takes the place of, say, bash/zsh/korn/fish shell scripts? Please don't say perl/python or sed/awk.

Lua. Very small runtime, fast, powerful.

Not installed anywhere by default

Re: The Bash Hackers Wiki

#38
post #9
post #3

Bash was the first scripting language I ever got "good" with. (I put "good" in quotes because while I could get basically anything done, I promise that it was not good looking). However, I feel like it left me a bit brain damaged, I still think in terms of quotation quirks and "sub-shells" even in proper languages such as python or rust. It also left me a bit weird when thinking about concurrency, because I never con…

Bash was the first scripting language I became “good” in too! The skill seems to be regularly devalued in this community, and there is no surprise why (what is collaboration and maintenance for $500). However, it’s hard to ignore why bash masters are born in the first place if better tools exist - shouldn’t the best tool win in the long run? My take is lone wolf hackers working in corporate /_/nix constrained environ…

I think in bash still. I know python and php, but I still think in bash.

Re: The Bash Hackers Wiki

#40
post #17
post #7

https://xkcd.com/927 Is there room for a lightweight scriptable language that takes the place of, say, bash/zsh/korn/fish shell scripts? Please don't say perl/python or sed/awk.

That's what Oil is, except it also runs bash scripts and lets you upgrade seamlessly. That is, bin/oil is the same as bin/osh with a bunch of shell options on, including 'shopt -s simple_word_eval' which eliminates a lot of the quoting hassles. You can try it now, but some things will be cut out after optimizing the prototype interpreter (in the name of time): You Can Now Try the Oil Language http://www.oilshell.org/…

Once Oil has better documentation I'll probably give it a try. The documents outlined in "Docs I Want to Write" seem promising and are still only visible as drafts in Zulip which requires logging in.
Post reply on HN