On 14.06.2012 00:42, Robert Mabee wrote:

> Having second thoughts.  Where I suggested taking out this call
> 
>> -      else if (isregexop (ch))
>> +      else if (ch == '*')    /* only wildcard currently implemented */
> I should have just taken the extraneous '.' out of isregexop.


It's used in other contexts as "needing escaping". So no, this part is fine

>  That would
> make it slightly simpler to add the remaining shell wildcards ('?' and '[')
> when desired.
> 
> '[' already works,

Not properly: try a[b*

> if there's also a * to trigger expansion, with the small
> bug that special chars within [] still get escaped or translated so the set
> may include an unexpected '.' or '\'.
> 
> Other regex chars also work, which probably should be counted as a
> bug.  I assume the eventual goal is to behave just like a common shell.

Please try attached patch
-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'grub-core/commands/wildcard.c'
--- grub-core/commands/wildcard.c	2012-06-08 20:54:21 +0000
+++ grub-core/commands/wildcard.c	2012-06-18 11:01:31 +0000
@@ -80,7 +80,7 @@ merge (char **dest, char **ps)
 static inline int
 isregexop (char ch)
 {
-  return grub_strchr ("*.\\", ch) ? 1 : 0;
+  return grub_strchr ("*.\\|+{}[]", ch) ? 1 : 0;
 }
 
 static char *
@@ -128,14 +128,22 @@ make_regex (const char *start, const cha
 	{
 	case '\\':
 	  buffer[i++] = ch;
-	  if (*start != '\0')
+	  if (*start == '*' || *start == '?')
 	    buffer[i++] = *start++;
+	  else
+	    buffer[i++] = '\\';
 	  break;
 
 	case '.':
 	case '(':
 	case ')':
 	case '@':
+	case '|':
+	case '+':
+	case '{':
+	case '}':
+	case '[':
+	case ']':
 	  buffer[i++] = '\\';
 	  buffer[i++] = ch;
 	  break;
@@ -145,6 +153,10 @@ make_regex (const char *start, const cha
 	  buffer[i++] = '*';
 	  break;
 
+	case '?':
+	  buffer[i++] = '.';
+	  break;
+
 	default:
 	  buffer[i++] = ch;
 	}
@@ -181,7 +193,7 @@ split_path (const char *str, const char
       if (ch == '\\' && end[1])
 	end++;
 
-      else if (isregexop (ch))
+      else if (ch == '*' || ch == '?')
 	regex = 1;
 
       else if (ch == '/' && ! regex)

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to