Skip to content

Instantly share code, notes, and snippets.

@lhns
Last active December 1, 2022 11:17
Show Gist options
  • Save lhns/6eca7b1ae27d9df9e7bf5be8d8ba15ce to your computer and use it in GitHub Desktop.
Save lhns/6eca7b1ae27d9df9e7bf5be8d8ba15ce to your computer and use it in GitHub Desktop.
exec {SUBSHELL_STDOUT_FD}>&1; eval "$({
set -e
trap 'while IFS= read -r SUBSHELL_VAR; do SUBSHELL_VAL="${!SUBSHELL_VAR}"; [[ "$SUBSHELL_VAR" != SUBSHELL_VAR ]] && [[ "$SUBSHELL_VAR" != SUBSHELL_VAL ]] && [[ "$SUBSHELL_VAR" != SUBSHELL_STDOUT_FD ]] && [[ "$SUBSHELL_VAR" != SUBSHELL_VARS_FD ]] && unset "$SUBSHELL_VAR" 2> /dev/null && printf "%q=%q\\n" "$SUBSHELL_VAR" "$SUBSHELL_VAL" || true; done < <(compgen -v) >&${SUBSHELL_VARS_FD}' EXIT
test=asdf6
echo output
false
} {SUBSHELL_VARS_FD}>&1 >&${SUBSHELL_STDOUT_FD}-)"; exec {SUBSHELL_STDOUT_FD}<&-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment