Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: exec -a and parameter expansion



On Jan 7,  5:56pm, Phil Pennock wrote:
} Subject: Re: exec -a and parameter expansion
}
} Unfortunately, my understanding of zsh's internal parse state is
} weak enough that I don't know the fix. Somewhere in the BINF_EXEC
} handling, I *think* that some kind of unmeta() is needed, but my naive
} approaches have not worked.

The problem here is that zsh does the following operations (this is all
in exec.c in the block before the comment "Do prefork substitutions"):

(1) Check that the command type is WC_SIMPLE;
(2) Check whether the first argument is a precommand modifier or other
special builtin ("exec" qualifies);
(3) Process options of those special builtins;
(4) Remove the precommand modifier or special builtin and its arguments
from the command line;
(5) "Do prefork substitutions"

Guess at which step variable expansion is performed?

Interestingly, if I simply move (5) up to before (1), I get EXACTLY
ONE failure from the "make check" test suite:

*** /tmp/zsh.ztst.out.31800     Fri Jan  7 18:08:59 2011
--- /tmp/zsh.ztst.tout.31800    Fri Jan  7 18:08:59 2011
***************
*** 1,4 ****
  1 1 0
! arg1 arg2
  noktarg1
  0 1
--- 1,4 ----
  1 1 0
! arg1
  noktarg1
  0 1
Test ../../zsh-4.0/Test/E01options.ztst failed: output differs from expected as
shown above for:
  setopt kshtypeset
  ktvars=(ktv1 ktv2)
  typeset ktfoo=`echo arg1 arg2` $ktvars
  print $+ktv1 $+ktv2 $+ktv3
  print $ktfoo
  unsetopt kshtypeset
  typeset noktfoo=`echo noktarg1 noktarg2`
  print $noktfoo
  print $+noktarg1 $+noktarg2
  unset ktfoo ktv1 ktv2 noktfoo noktarg2
Was testing: KSH_TYPESET option

So either there are some missing test cases for other things that
this would cause to break, or we should rearrange execcmd() so that
"typeset" is the only special-cased builtin ahead of prefork().

-- 



Messages sorted by: Reverse Date, Date, Thread, Author