Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
The sh substitution problem.
- X-seq: zsh-workers 17309
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx (Zsh hackers list)
- Subject: The sh substitution problem.
- Date: Mon, 10 Jun 2002 13:05:14 +0100
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
namely ${1+"$@"} when using `sh' word-spliting makes a scalar out of "$@"
and splits it later on, with consequent undesirable effects.
I thought I had a way of doing the important cases (i.e. the ones
required for POSIX) simply but it turns out it doesn't work. We just
have a completely different notion of how a command line word is formed
(because ours is more logical :-)). So I've given that up.
I have a vague plan for doing it `properly' but it doesn't fill me with
delight:
- When calling prefork() from multsub(), don't remove nulls (hence
preserving information about quotes, which are retained as Snull,
Dnull and Bnull).
- In multsub(), handle arrays properly, i.e. stick the results in what
is currently its second argument. This will have knock-on effects
since paramsubst() messes around with val and aval all the time. The
way mult_isarr has been hacked in to avoid the calling sequence may
make this more difficult. (Ideally we would replace mult_isarr by
making multsub() always return arrays. This is probably even harder,
but I don't understand the details of mult_isarr, which handles
nested substitutions, well enough to say.)
[It might be possible to keep val and aval as a pair in a structure,
a sort of pseudo-parameter, and only convert between scalar and array
when really necessary with a `forcescalar' or `forcearray'
function/macro.]
- Avoid joining words before splitting them (unless it is a forced
join with a given string). This changes the current rules but is
inevitable for getting this to work at all. This probably also means
handling certain types of scalar result by joining arrays at this point
instead of before (even if they are not going to be split). This is
also probably tricky because there are umpteen different ways of
ending up with a scalar. This is probably where we would have to do
any joining due to letting multsub() always return an array. I used
the word `probably' three times in that paragraph.
- When splitting, handle a loop over multiple array elements and
keep track of quotes. This also fixes:
% ARGV0=sh zsh
$ set word
$ print -l ${1+'this should not be split'}
this
should
not
be
split
This is tricky and I have no idea of its detailed feasibility. If
anyone wants to try they should. Otherwise just make comments.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author