File boo1227807.patch of Package bash.35311

Fix bug boo#1227807 that is allow loading of a completion
file even if a {} as brace expansion us used on the
command line, e.g.

  zypper se l{abc} yyy<TAB>

---
 bashline.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

--- bashline.c
+++ bashline.c	2024-08-21 11:50:21.288081246 +0000
@@ -1329,6 +1329,28 @@ find_cmd_start (start)
 	  os = ns+1;
 	  continue;
 	}
+      /* The only reserved word in COMMAND_SEPARATORS is `{', so handle that
+	specially, making sure it's in a spot acceptable for reserved words */
+      if (s >= os && rl_line_buffer[s] == '{')
+	{
+	  int pc, nc;   /* index of previous non-whitespace, next char */
+	  for (pc = (s > os) ? s - 1 : os; pc > os && whitespace(rl_line_buffer[pc]); pc--)
+	    ;
+	  nc = rl_line_buffer[s+1];
+	  /* must be preceded by a command separator or be the first non-
+	     whitespace character since the last command separator, and
+	     followed by a shell break character (not another `{') to be a reserved word. */
+	  if ((pc > os && (rl_line_buffer[s-1] == '{' || strchr (COMMAND_SEPARATORS, rl_line_buffer[pc]) == 0)) ||
+	      (shellbreak(nc) == 0))    /* }} */
+	    {
+	      /* Not a reserved word, look for another delim */
+	      ns = skip_to_delim (rl_line_buffer, s+1, COMMAND_SEPARATORS, SD_NOJMP|SD_COMPLETE/*|SD_NOSKIPCMD*/);
+	      if (ns > start || rl_line_buffer[ns] == 0)
+		return os;
+	      os = ns+1;
+	      continue;
+	    }
+	}
       os = s+1;
     }
   return os;
openSUSE Build Service is sponsored by