r/bash • • 14h ago

submission Working on the Bash interpreter in JavaScript

0 Upvotes

I'm working on the Bash interpreter (Unix env) and making use of an old domain:

hacking.cafe.

The code is open source on the AGPL license available on GitHub.

I was thinking about making the bash interpreter part a library on a less restrictive license.

The README includes bash features that I've implemented so far.

I'm using ubash JavaScript parser.


r/bash • • 22h ago

Replacing dirname with only builtins

3 Upvotes

I am writing a bunch of scripts for which I want to only use builtins and realised that dirname is not a builtin, I replaced it thusly:

SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SRC_DIR2="$({ cd "${BASH_SOURCE[0]%/*}" 2>/dev/null || :; } && pwd)"

I think these two lines are functionally equivalent, considering that BASH_SOURCE[n] will never contain a trailing /.

Then again I am often stupid. Does anyone see any issues?