Author: mav
Date: Fri Dec 13 17:52:09 2019
New Revision: 355718
URL: https://svnweb.freebsd.org/changeset/base/355718

Log:
  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.

Modified:
  head/sbin/devd/devd.cc

Modified: head/sbin/devd/devd.cc
==============================================================================
--- head/sbin/devd/devd.cc      Fri Dec 13 16:51:56 2019        (r355717)
+++ head/sbin/devd/devd.cc      Fri Dec 13 17:52:09 2019        (r355718)
@@ -681,15 +681,15 @@ config::expand_one(const char *&src, string &dst, bool
        // 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;
        }
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to