From 338cdc646f1f7df4bb7ed4373c686c4eca74d180 Mon Sep 17 00:00:00 2001 From: Nick Chambers Date: Sun, 25 Jul 2021 20:37:56 -0500 Subject: [PATCH] bash/whitespace.sh: hack for allowing normal looking assignments --- bash/whitespace.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bash/whitespace.sh diff --git a/bash/whitespace.sh b/bash/whitespace.sh new file mode 100644 index 0000000..4db2de7 --- /dev/null +++ b/bash/whitespace.sh @@ -0,0 +1,16 @@ +command_not_found_handle() { + if [[ $2 != =* ]]; then + printf '%s: %s: command not found\n' "$0" "$1" >&2 + fi +} + +make_assign() { + local name equal value + read -r name equal value <<< "$BASH_COMMAND" + + if [[ $equal = =* ]]; then + declare -g "$name$equal$value" + fi +} + +trap make_assign DEBUG