pure-bash-bible
pure-bash-bible copied to clipboard
📖 A collection of pure bash alternatives to external processes.
Read and write a file including nulls, pure bash, no externals, no sub-shell forks. not limited to late versions. Slow and ram-hungry. Every byte is read one byte at a...
As the second argument can be unbound in `basename`, the following script will fail: ```bash #!/usr/bin/env bash set -u basename() { # Usage: basename "path" ["suffix"] local tmp tmp=${1%"${1##*[!/]}"} tmp=${tmp##*/}...
This has bitten me multiple times, not sure if there is a good place for it in the book? When a function accepts optional parameters for arg1, and arg2, and...
[[ 1 == 1 ]] && { command exit 1 } || { this command will exec } how to avoid???
Definitely nice to use `&&` as a shorter `if`, but there are caveats, when using `&&` in a function. This is probably the single largest error I used to make....
A slightly nicer alternative to the proposed solution would be ```sh split_string() { # Usage: split_string "string" "delimiter" printf '%s\n' "${1//$2/$'\n'}" } ``` No need for creating an array first.
Hi. I'm new to your project, and am starting at the beginning (no guarantee I'll continue)... In your very first snippet, labeled "Trim leading and trailing white-space from string", you...
Add a command line argument parsing example