Home | History | Annotate | Download | only in sh
History log of /src/tests/bin/sh/t_expand.sh
RevisionDateAuthorComments
 1.23  06-Mar-2023  kre Adjust the tilde expansion test to deal with (very) recent changes
to what the shell produces for tilde expansions, when the expansion
of the tilde prefix ends with '/' and the character immediately following
is another '/' - previously /bin/sh (and most other shells, but not all)
retained both slashes, and this test expected that behaviour.

No longer, now only one of the two will appear. Adjust the expected
test results accordingly, and add an extra loop iteration to make sure
this is thoroughly tested (one more tilde expansion value).

Also, add two new test cases that test for the new (explicit - though
it was always stated this way, but not as explicitly) that if HOME is
an empty string (not unset - that remains an unspecified case, as it
was) then the expansion of ~ must generate "", and not nothing.
The current test was unable to distinguish those two, since it
simply looked for characters in the output, so add a new test cases
explicitly to test for this particular case. This also means (also
previously in the standard, but not as explicitly) that shells are
not permitted to decide "The ~ expansion produces an empty string, that
is weird, let's generate something else instead" which some shells were
doing.
 1.22  04-May-2019  kre Fix an (apparent) ancient ash bug, that was apparently fixed sometime
in the past, but managed to re-surface...

The expression "${0+\}}" should expand to "}" not "\}"
Almost all other shells handle it that way (incl FreeBSD & dash).

Issue pointed out by Martijn Dekker.

Add ATF sub-tests for the 4 old var expand operators (${var+word}
${var-word} ${var-word} and ${var?word} - including the forms
with the ':' included) and amongst those tests include test cases
for this issue, so if the bug tries to appear again, we can squash
it quicker. (The newer pattern matching operators are already
well tested as part of testing patterns.)
 1.21  10-Apr-2019  kre PR bin/54112

Fix handling of "$@" (that is, double quoted dollar at), when it
appears in a string which will be subject to field splitting.

Eg:
${0+"$@" }

More common usages, like the simple "$@" or ${0+"$@"} end up
being entirely quoted, so no field splitting happens, and the
problem was avoided.

See the PR for more details.

This ends up making a bunch of old hack code (and some that was
relatively new) vanish - for now it is just #if 0'd or commented out.
Cleanups of that stuff will happen later.

That some of the worst $@ hacks are now gone does not mean that processing
of "$@" does not retain a very special place in every hackers heart.
RIP extreme ugliness - long live the merely ordinary ugly.

Added a new bin/sh ATF test case to verify that all this remains fixed.
 1.20  27-Nov-2018  kre Add two new test cases to add more tests for $@ expansions
(and a few more subtests in an existing test case).

The two new test cases currently fail, because of issues with
expanding "${1+$@}" which will (hopefully) be fixed soon.
(This looks to have been broken sometime during 2013 ... then I
made it even worse with some of the parser changes a while ago,
though the end result is that it appears less broken than it
really is.)
 1.19  21-Apr-2018  kre branches: 1.19.2;

Add a test case for PR bin/53201

Currently this test case will fail, a fix is coming soon (not worth
marking this as an expected failure.)

This test case and the initial bug report comes from
Martijn Dekker's modernish (shell/test set).
 1.18  06-Oct-2017  kre branches: 1.18.2;

Add a new sub-test to validate ~ expansions.

Currently testing ~user is too much effort to contemplate (other than
assuming that it works in order to verify that it works...) so only bare ~
is being tested for now. Maybe someday...

Right now (@ time of commit), this new test is expected to fail, as ~
expansions are horribly badly broken (have been for months, some forms
for much longer) in all but the simplest of uses. Fix for that coming
very soon.
 1.17  03-Jun-2017  kre Complete the special request by quoting chapter & verse from POSIX
as to why ${011} is ${11} and not ${9} (that is, why we interpret it
that way, the "why could it not be the other way?" is just "because
that is not how it was ever implemented".
 1.16  03-Jun-2017  kre By special request, add a check that ${011} is ${11} not ${9} (etc) and
that ${08} is not an error.
 1.15  02-Jun-2017  kre Add 3 new subtests to the shell_params test case. These test currently
broken behaviour (so for now, 3 of 15 subtests will fail). This will
be corrected later today.
 1.14  29-May-2017  kre Add a new test case wrap_strip based upon strip (ie: cut&paste.. to start)
but with \ newline line continuations inserted at strange places.

For the shell as it is today, since strip passes, wrap_strip should
automaticallty pass as well (and does), as the \ newline combination
is simply removed, producing identical input to that of strip.

However, for accurate line counting ($LINENO: coming soon) newlines (no
matter the context) cannot simply "go away" - we have to know where they
occur(ed) (perhaps long after the text was read) so we know what line
number we are actually processing. This new test case is (perhaps just
part) of future-proofing that the modified code does not break anything.
 1.13  15-May-2017  kre More test sub-cases for the dollar_hash ( ${#...} ) test.
Upi really (really!) don't want to know!

Also, add a comment (in another section) and avoid giving messages
to atf_fail that include newlines - AFT really doesn't like that.
Instead, convert the \n's to ;'s so at least the content is retained.
 1.12  14-May-2017  kre Add a test case for the various ways that ${xxx} expansions, which
contain a # character, can get parsed (which amounts to 86 extra checks,
any Australian can tell you why I decided to stop there and not add one
more...)
 1.11  20-Mar-2017  kre branches: 1.11.2;

PR bin/52090 - the $* tests are no longer expected to fail.
 1.10  19-Mar-2017  kre PR bin/52090

Add 5 new test cases to test various ways that $* can be expanded.
Currently 3 of the 5 are marked as "expected to fail" because of the
bug in this PR.
 1.9  12-Mar-2017  kre Add new test case in to check (coming) bug fix for newly discovered
ash based shell bug
echo ${unset_var##$(echo a)}$(echo b)
should say "b" but instead says "a" ... the first "echo a" is not
evaluated because it cannot possibly match an unset variable, but is
not removed from the list of command substitutions, when the shell
needs to execute the 2nd cmdsub, "echo b" should be at the head of
the list, but isn't, "echo a" is still there...

This test should fail (for now) - should show 4 of 40 subtests failing.
It isn't marked as atf_expect_fail as the fix for this will be coming
later today (I will just wait at least 1 b5 build cycle so the failure
can be observed).

Detecting the bug, and the fix, are from FreeBSD.
 1.8  29-Apr-2016  christos branches: 1.8.2; 1.8.4;
use "" so ${TEST_SH} is expanded.
 1.7  31-Mar-2016  christos PR bin/51027 - tests for shell positional parameters, including
testing that $10 is correctly parsed as ${1}0 and not as ${10}.
More than that though. (from kre@)
 1.6  08-Mar-2016  christos Added more test cases, more exhaustive testing. (from kre)
 1.5  22-Feb-2016  christos PR/43469 has been fixed
 1.4  19-Feb-2016  christos undo accidental commit
 1.3  19-Feb-2016  christos Add a test for PR/50827
 1.2  06-Oct-2013  ast Fix PR bin/48202 [non-critical/low]:
sh +nounset and `for X; do` iteration fails if parameter set empty
by applying and testing FreeBSD's patch of Oct 24 2009 for this; see
http://svnweb.freebsd.org/base/head/bin/sh/expand.c?r1=198453&r2=198454
Also created an ATF test in tests/bin/sh/t_expand.sh for this error and
corrected a space->tabs problem there as well.
 1.1  17-Mar-2012  jruoho branches: 1.1.2; 1.1.4;
Deprecate tests/util.
 1.1.4.1  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.2.2  17-Apr-2012  yamt sync with head
 1.1.2.1  17-Mar-2012  yamt file t_expand.sh was added on branch yamt-pagecache on 2012-04-17 00:09:02 +0000
 1.8.4.1  21-Apr-2017  bouyer Sync with HEAD
 1.8.2.2  26-Apr-2017  pgoyette Sync with HEAD
 1.8.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.11.2.1  19-May-2017  pgoyette Resolve conflicts from previous merge (all resulting from $NetBSD
keywork expansion)
 1.18.2.2  26-Dec-2018  pgoyette Sync with HEAD, resolve a few conflicts
 1.18.2.1  22-Apr-2018  pgoyette Sync with HEAD
 1.19.2.1  10-Jun-2019  christos Sync with HEAD

RSS XML Feed