Today I Learned

2023/10/31

sh posix js

That POSIX shell has configuration option, set -a or set -o allexport that exports all assigned variables. This simplifies using .env files in .envrc files:

# evaluate a .env file, if it exists
if [ -f .env ]; then
  set -a # assigning a variable exports the variable
  # shellcheck disable=SC1091
  source .env
  set +a
fi

That JS has a String.raw template literal tag function that unescapes escape sequences in a backtick-string:

String.raw`\t\r\n` // => "\\t\\r\\n"