-
-
Save d630/4fa0de79fddb74bfc5aadacf2570c4c1 to your computer and use it in GitHub Desktop.
bash: bash: bash: bash:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# No local scope, use command substitution, process | |
# substitution, regular pipes or execute external procedures/scripts. | |
# | |
# Use set -o allexport, if you like to be oldschool. | |
#mapfile -t -c 1 -C "printf '%.0s%s\n'" -u 7 "${FUNCNAME[1]%%.*}" | |
function fn.call { | |
typeset -n a="${FUNCNAME[1]%%.*}"; | |
[[ -v a[0] ]] || "${FUNCNAME[1]%%.*}.load" "$@"; | |
printf '%s\n' "${a[@]}"; | |
}; | |
function fn.load { | |
mapfile -t -u 7 "${FUNCNAME[1]%%.*}"; | |
}; | |
function code1.call { fn.call "$@"; }; | |
function code1.load { fn.load; } 7<<code1 | |
echo "$1"; | |
echo yes!!; | |
echo bye; | |
typeset +i foo=$1; | |
code1 | |
function code2.call { fn.call "$@"; }; | |
function code2.load { fn.load; } 7<<code2 | |
echo no; | |
echo no!!!; | |
echo bye; | |
code2 | |
# -- MAIN. | |
echo "${1:-: ok, mister mix}"; | |
'code2.load'; | |
: && . <('code1.call' "yes") || . <('code2.call'); | |
! : && . <('code1.call' "yes") || . <('code2.call'); | |
. <('code1.call' yes); | |
. <('code2.call' xsadas); | |
'code1.load' "no"; | |
typeset -p foo code{1,2}; | |
eval "${code1}"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to run?