Skip to contentSkip to conversation

Complete 'set root=('

PATCH In review Colin Watson 2 participants 2 messages Jun 3, 2010 – Jun 7, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Complete 'set root=('

While reviewing the Texinfo documentation for references to GRUB Legacy constructs that needed to be updated, I found some discussion of completion that used "root (<TAB>" as an example. For GRUB 2, this would need to become "set root=(<TAB>" - but that doesn't work! The completion code isn't smart enough to complete only the part after the '=' in this case.

What do people think about the following patch, which makes this work so that we can document it with a clear conscience?

2010-06-03 Colin Watson <[email protected]>

* normal/completion.c (grub_normal_do_completion): When completing arguments to "set" and the current word contains an equals sign, skip to after the equals sign before starting completion.

=== modified file 'normal/completion.c'

completion.c +8 -0
@@ -414,6 +414,14 @@ grub_normal_do_completion (char *buf, in
   else
     current_word = argv[argc - 1];
 
+  if (argc > 1 && ! grub_strcmp (argv[0], "set"))
+    {
+      char *equals = grub_strchr (current_word, '=');
+      if (equals)
+	/* Complete the value of the variable.  */
+	current_word = equals + 1;
+    }
+
   /* Determine the state the command line is in, depending on the
      state, it can be determined how to complete.  */
   cmdline_state = get_state (buf);

Thanks,

Signature · 1 line
Colin Watson                                       [[email protected]]
#1 lore raw

Go ahead.

Quoted 39 lines · Colin Watson

While reviewing the Texinfo documentation for references to GRUB Legacy constructs that needed to be updated, I found some discussion of completion that used "root (<TAB>" as an example. For GRUB 2, this would need to become "set root=(<TAB>" - but that doesn't work! The completion code isn't smart enough to complete only the part after the '=' in this case.

What do people think about the following patch, which makes this work so that we can document it with a clear conscience?

2010-06-03 Colin Watson <[email protected]>

* normal/completion.c (grub_normal_do_completion): When completing arguments to "set" and the current word contains an equals sign, skip to after the equals sign before starting completion.

=== modified file 'normal/completion.c'

completion.c +8 -0
@@ -414,6 +414,14 @@ grub_normal_do_completion (char *buf, in
   else
     current_word = argv[argc - 1];
 
+  if (argc > 1 && ! grub_strcmp (argv[0], "set"))
+    {
+      char *equals = grub_strchr (current_word, '=');
+      if (equals)
+	/* Complete the value of the variable.  */
+	current_word = equals + 1;
+    }
+
   /* Determine the state the command line is in, depending on the
      state, it can be determined how to complete.  */
   cmdline_state = get_state (buf);

Thanks,

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko