-
-
Save ormaaj/e3ac2db565bb9166ec9c5a5197638010 to your computer and use it in GitHub Desktop.
ksh empty array subscripts
This file contains hidden or 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
(ins)ormaaj 65 (2713681) 2 ~ $ function f { unset -f f; typeset -ia fd; typeset -n fdn=fd[\${#fd[@]}]; { env -- BASH_FUNC_pre_pkg_{pretend,setup}'%%=() { function tc-check-openmp { return 0; }; }' execlineb -- "/proc/self/fd/${fd[0]}" "${fd[@]}"; } {fdn}<<\EOF {fdn}<<\EOF; typeset x; for x in "${fd[@]}"; do exec {x}<&-; done; }; f | |
fdreserve 1 | |
multisubstitute { | |
importas -iu f0 FD0 | |
elgetpositionals | |
} | |
emptyenv -P | |
fdclose $1 | |
define -sd " " v "${2} ${f0}" | |
creatememfd $f0 "" | |
foreground { cp -Lf -- /proc/self/fd/${v} } | |
foreground { printf -- ---\\n\\n } | |
fdclose $2 | |
export sh ksh | |
/proc/self/fd/${f0} | |
EOF | |
#!/usr/bin/env -S -a ksh -u ? -- ${sh} -- | |
function _m { | |
typeset k= | |
typeset -A v=([x]=a [y]=A) | |
typeset -n r | |
for r in "${!v[@]}"; do | |
set -x | |
eval typeset "-${v[${!r}]}" -- 'r=([${k}]=)' | |
set +x | |
done | |
echo | |
print -C -- "${!v[@]}" | paste -sd ' ' | |
echo | |
} | |
_m "$@" | |
case $sh in (ksh) sh+=v;; (*) sh=true; esac | |
exec -- "${.sh.file}" "$@" {in}<&0 <&"${.sh.file##*/}" <#((0)) <&"$in"- | |
EOF | |
--- | |
+ eval typeset -a -- r='([${k}]=)' | |
+ x[0]='' | |
+ typeset -a -- r | |
+ eval typeset -A -- r='([${k}]=)' | |
/proc/self/fd/3[17]: _m[9]: eval: line 1: warning: adding empty subscript | |
+ y['']='' | |
+ typeset -A -- r | |
('') (['']='') | |
+ eval typeset -a -- r='([${k}]=)' | |
+ x[0]='' | |
+ typeset -a -- r | |
+ eval typeset -A -- r='([${k}]=)' | |
/proc/self/fd/3[17]: _m[9]: eval: line 1: warning: adding empty subscript | |
+ y['']='' | |
+ typeset -A -- r | |
('') (['']='') | |
(ins)ormaaj 65 (2713681) 0 ~ $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment