From bac660f87b7559d89d25d3522563525d6c5e9ebf Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 12 Apr 1999 09:07:36 +0000 Subject: Update. 1999-04-11 Tim Waugh * posix/wordexp.c (wordexp): Fix a leak when an invalid character is seen, as well as fixing semantics. Don't reset the word count to zero when an invalid character is seen, but leave it as it was (this makes a difference with WRDE_APPEND). * posix/wordexp-test.c: More test cases. * posix/wordexp.c (parse_param): In words like ${var#pattern}, always expand pattern when it is needed. Also, handle quoting in pattern properly. --- posix/wordexp-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'posix/wordexp-test.c') diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c index 8e709c7..21bca96 100644 --- a/posix/wordexp-test.c +++ b/posix/wordexp-test.c @@ -81,6 +81,7 @@ struct test_case_struct { 0, NULL, "\"quoted\"", 0, 1, { "quoted", }, IFS }, { 0, "foo", "\"$var\"\"$var\"", 0, 1, { "foofoo", }, IFS }, { 0, NULL, "'singly-quoted'", 0, 1, { "singly-quoted", }, IFS }, + { 0, NULL, "contin\\\nuation", 0, 1, { "continuation", }, IFS }, /* Simple command substitution */ { 0, NULL, "$(echo hello)", 0, 1, { "hello", }, IFS }, @@ -118,10 +119,16 @@ struct test_case_struct { 0, NULL, "${var:-'}'}", 0, 1, { "}", }, IFS }, { 0, NULL, "${var-}", 0, 0, { NULL }, IFS }, + { 0, "pizza", "${var#${var}}", 0, 0, { NULL }, IFS }, + { 0, "pepperoni", "${var%$(echo oni)}", 0, 1, { "pepper" }, IFS }, + { 0, "6pack", "${var#$((6))}", 0, 1, { "pack" }, IFS }, + { 0, "b*witched", "${var##b*}", 0, 0, { NULL }, IFS }, + { 0, "b*witched", "${var##\"b*\"}", 0, 1, { "witched" }, IFS }, { 0, "banana", "${var%na*}", 0, 1, { "bana", }, IFS }, { 0, "banana", "${var%%na*}", 0, 1, { "ba", }, IFS }, { 0, "borabora-island", "${var#*bora}", 0, 1, { "bora-island", }, IFS }, - { 0, "borabora-island", "${var##*bora}", 0, 1, {"-island", }, IFS }, + { 0, "borabora-island", "${var##*bora}", 0, 1, { "-island", }, IFS }, + { 0, "coconut", "${var##\\*co}", 0, 1, { "coconut", }, IFS }, { 0, "100%", "${var%0%}", 0, 1, { "10" }, IFS }, /* Pathname expansion */ -- cgit v1.1