NetBSD/bin
kre df073671e8 Rationalise (slightly) the way that expansions are processed
to hide meta-characters in the result when the expansion was
in (double) quotes, and so should not be further processed.

Most of this has been OK for a long while, but \ needs hiding
as well, which complicates things, as \ cannot simply be hidden
in the syntax tables as one of the group of random special characters.

This was fixed earlier for simple variable expansions, but
every variety has its own code path ($var uses different code
than $n which is different than $(...), which is different
again from ~ expansions, and also from what $'...' produces).

This could be fixed by moving them all to a common code path,
but that's harder than it seems.  The form in which the data
is made available differs, so one common routine would need
a whole bunch of different "get the next char or indicate end"
methods - probably via passing in an accessor function.
That's all a lot of churn, and would probably slow the shell.

Instead, just make macros for doing the standard tests, and
use those instead of open coding (differently) each time.
This way some of the code paths don't end up forgetting to
handle '\' (which is different than all the others).

This removes one optimisation ... when no escaping is needed
(like just $var (unquoted) where magic chars (think '*') in
the value are intended to remain magic), the code avoided doing
two tests for each char ("do we need escapes" and "is this char
one that needs escaping") by choosing two different syntax
tables (choice made outside the loop) - one of which never
returns the magic "needs escaping" result, and the other does
when appropriate, and then just avoiding the "do we need escapes"
test for each character processed.   Then when '\' was fixed,
there needed to be another test for it, as it cannot (for other
reasons) be the same as all the others for which "this char
need escaping" is true.   So that added a 2nd test for each char...
Not all the code paths were updated.   Hence the bugs...

nb: this is all rarely seen in the wild, so it is no big
surprised that no-one ever noticed.

Now the "use two different syntax tables" is gone (the two
returned the same for '\' which is why '\' needed special
processing) - and in order to avoid two tests for each
char (plus the \ test) we duplicate the loops, one of which
tests each char to see if it needs an escape, the 2nd just
copies them.   This should be faster in the "no escapes"
code path (though that is not the point) and perhaps also
in the "escapes needed" path (no indirect reference to
the syntax table - though that would probably be in a
register) but makes the code slightly bigger.  For /bin/sh
the text segment (on amd64) has grown by 48 bytes.  But
it still uses the same number of 512 byte pages (and hence
also any bigger page size).  The resulting file size
(/bin/sh) is identical before and after.  So is /rescue/sh
(or /rescue/anything-else).
2018-11-18 17:23:37 +00:00
..
cat Add cross reference to tac(1). 2017-10-02 08:24:17 +00:00
chio typo: unvalid -> invalid 2017-10-16 17:08:35 +00:00
chmod Use Ex. 2017-07-04 06:46:51 +00:00
cp Re-order the code to short circuit all the opens and closes if linking. 2018-07-17 13:04:58 +00:00
csh use SUBDIR.roff suggested by uwe@ 2018-06-10 17:55:11 +00:00
date Remove trailing whitespace and Tn macro. 2018-01-27 18:59:38 +00:00
dd Use Ex. 2017-07-04 06:46:51 +00:00
df -G cannot be specified alongside -i or -P. 2018-08-26 23:34:52 +00:00
domainname
echo Use Ex. 2017-07-04 06:46:51 +00:00
ed Prevent shell execution also in the 'r ! dobad' case, pointed out by 2018-06-18 14:56:24 +00:00
expr Add a missing check to handle correctly 0 * 0 in expr(1) 2018-06-27 17:23:36 +00:00
hostname
kill Switch from using two printsignals() functions, one in trap.c 2018-10-28 18:26:52 +00:00
ksh Add -l to SYNOPSIS 2018-08-26 22:52:34 +00:00
ln Update usage to include -w 2018-08-26 23:01:06 +00:00
ls Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
mkdir Use Ex. Remove superfluous Pp. 2017-07-04 06:49:35 +00:00
mt Bump date for previous. 2018-09-01 07:26:56 +00:00
mv Use Ex. 2017-07-04 06:50:04 +00:00
pax PR/53362: Thomas Barabosch: Use strlcpy() to prevent theoretical buffer 2018-06-13 15:14:40 +00:00
ps Don't display l_wchan, either there is something in l_wmesg and we display 2018-09-19 15:20:39 +00:00
pwd Use Ex. 2017-07-04 06:50:04 +00:00
rcmd Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
rcp
rm Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
rmdir PR/48182: Fix rmdir -p handling of top-level (root) directory. 2017-08-10 22:52:13 +00:00
sh Rationalise (slightly) the way that expansions are processed 2018-11-18 17:23:37 +00:00
sleep Remove workaround for ancient HTML generation code. 2017-07-03 21:28:48 +00:00
stty Remove Tn. 2017-10-30 15:38:52 +00:00
sync
test Allow SMALL (and TINY) builds of test (for SMALL/TINY builds of sh) 2018-09-13 22:00:58 +00:00
Makefile
Makefile.inc