From 50f8fa972c3795a115e7faff0b4c140b40eab5f0 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Wed, 21 Nov 2018 10:10:03 +0000
Subject: 43837 plus test from Daniel: Empty string in nested subst.
Skip Nularg or there is a bogus character at the start.
---
ChangeLog | 6 ++++++
Src/subst.c | 2 ++
Test/D04parameter.ztst | 7 +++++++
3 files changed, 15 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index ced545aaf..69a94687c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-11-21 Peter Stephenson
+
+ * 43837 (test from Daniel): Src/subst.c, Test/D04parameter.ztst:
+ Nested substitution didn't remove Nularg from empty string,
+ giving bogus character.
+
2018-11-19 Jun-ichi Takimoto
* 43829: Src/Modules/nearcolor.c: use double instead of float
diff --git a/Src/subst.c b/Src/subst.c
index c706b9688..ff6750a59 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2405,6 +2405,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
aspar = 0;
} else if (aspar)
idbeg = val;
+ if (*val == Nularg)
+ ++val;
*s = sav;
/*
* This tests for the second double quote in an expression
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index e327a784c..7ab2384aa 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -2430,3 +2430,10 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
)
0:Use of parameter subst + to test element of hash with KSH_ARRAYS.
>0
+
+ for baz in "" "inga"; do
+ echo ${#${baz}} "${#${baz}}" ${#baz} "${#baz}"
+ done
+0:double-quoted nested evaluation of empty string
+>0 0 0 0
+>4 4 4 4
--
cgit 1.4.1