Hi, Quoting POSIX on the command utility: 82858 If the command_name is the same as the name of one of the special built-in utilities, the special 82859 properties in the enumerated list at the beginning of Section 2.14 (on page 2356) shall not occur.
This suggests it should be possible to negate the effects of a special builtin by prefixing the "command" regular builtin. In ksh, "command" suppresses function lookup with no impact on the environment or evaluation order. $ x=5 command true; typeset -p x; y=5 command :; typeset -p y y=5 $ _=$(print -rn '1 ' >&2) command : <&0$(print -rn '2 ' >&2); print 1 2 $ _=$(print -rn '1 ' >&2) command true <&0$(print -rn '2 ' >&2); print 2 1 "unalias command" made no difference. I came up with the following scheme to approximate local variables in POSIX shells. Most current shells produce correct output, except ksh and zsh. (This is apparently a regression in the case of zsh): f() { if [ -n "${_called_f+_}" ]; then for x; do printf '%s, ' "$x" done else _called_f= x= command eval '{ typeset +x x; } 2>/dev/null; f "$@"' fi } x='outside f' printf "$x, " f 1 2 3 echo "$x" # Results: # bash --posix: "outside f, 1, 2, 3, outside f" # dash: "outside f, 1, 2, 3, outside f" # mksh: "outside f, 1, 2, 3, outside f" # posh: "outside f, 1, 2, 3, outside f" # ksh93u (2012-08-01): "outside f, 1, 2, 3, 3" # zsh (emulate sh): "outside f, 1, 2, 3," Thanks -- Dan Douglas
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ ast-developers mailing list ast-developers@research.att.com https://mailman.research.att.com/mailman/listinfo/ast-developers