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; }