
bash is a language, and also a religion. Like Jesus, it was bourne again.
Joined February 2019
- Tweets31
- Following5
- Followers44
- Likes0
If the script needs an env var for a single command, instead of:
```
export MYENV=val
my_command
```
use this construct:
```
MYENV=val my_command
```
and now MYENV won't bleed to the rest of the script.
1
To find the path of a program, use `type -p` instead of `which`. `type -p` is a built-in command and therefore available everywhere.
Project highlight: github.com/abathur/resholve
A tool that replaces external programs with absolute paths.
3
The Oil shell project is one of the most extensive re-implementation of Bash out there.
Check out @oilshellblog
/ oilshell.org
5
the way of bash retweeted
direnv v2.23.0 has been released!
It adds `direnv fetchurl <URL> [<integrity-hash>]` as a content-addressable wget replacement.
And stdlib `source_url <URL> <integrity-hash>` function that can be used to security load bash scripts from the Internet.
github.com/direnv/direnv/rel…
ChaCha20 implemented in pure Bash.
git.zx2c4.com/chacha20.sh/tr…
Thanks @flokli for the link!
2
The Bernstein-chaining version of:
bash -c "echo sub command 'need quoting'"
Is:
bash -c '"$@"' argv0 echo sub command "need quoting"
It's a bit more verbose but it avoids having to escape arguments.
The pure Bash bible has made a lot of progress since last posted. It's now a good reference material for day-to-day Bash programming.
github.com/dylanaraps/pure-b…
github.com/bashup/events -
Callback events library written in pure bash
2
The unofficial Bash Strict Mode:
redsymbol.net/articles/unoff…
1
A good default shebang:
```
#!/usr/bin/env bash
set -euo pipefail
```
Not everybody has bash installed in /usr/bin/bash.
Abort on error.
Catch unused variables.
Abort if any programs in the pipe fail.
3
Bash is great for writing web servers for mobile apps!
github.com/lheckemann/presre…
3
the way of bash retweeted
Wrote about coprocesses in Bash.
coproc is a way of spawning a subprocess asynchronously. It lets a shell communicate with the subprocess since the input and output file descriptors are available to the shell.
But not without gotchas.
medium.com/@copyconstruct/ba…
Seven Surprising Bash Variables
zwischenzugs.com/2019/05/11/…
2
shfmt can be used to format bash scripts:
github.com/mvdan/sh
2
Bash only takes 5.8M on disk. In 2019 it is acceptable for scripts to not be cross-shell compatible and only target bash.
ShellCheck is a bash linter and almost a requirement when writing any script.
shellcheck.net/
1
$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin18)
Copyright (C) 2007 Free Software Foundation, Inc.
This is the version that is shipping on MacOS Mojave and is basically useless.
Shame on @Apple for shipping a 12 year old software with no upgrades.

