Fix $() handling, broken since the beginning at r108014.

Due to off-by-one error in brackets counting it consumed the rest of the
string, preventing later variables expansions.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
This commit is contained in:
Alexander Motin 2019-12-13 17:52:09 +00:00
parent c3eda7cbf1
commit de57976691
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=355718

View File

@ -681,15 +681,15 @@ config::expand_one(const char *&src, string &dst, bool is_shell)
// This is the escape hatch for passing down shell subcommands // This is the escape hatch for passing down shell subcommands
if (*src == '(') { if (*src == '(') {
dst += '$'; dst += '$';
count = 1; count = 0;
/* If the string ends before ) is matched , return. */ /* If the string ends before ) is matched , return. */
while (count > 0 && *src) { do {
if (*src == ')') if (*src == ')')
count--; count--;
else if (*src == '(') else if (*src == '(')
count++; count++;
dst += *src++; dst += *src++;
} } while (count > 0 && *src);
return; return;
} }