From de579766917e560eb880a7a13688d931116c97aa Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Fri, 13 Dec 2019 17:52:09 +0000 Subject: [PATCH] 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. --- sbin/devd/devd.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index afd57d452f06..a1b6ee479921 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -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 if (*src == '(') { dst += '$'; - count = 1; + count = 0; /* If the string ends before ) is matched , return. */ - while (count > 0 && *src) { + do { if (*src == ')') count--; else if (*src == '(') count++; dst += *src++; - } + } while (count > 0 && *src); return; }