[PATCH 1/6] complete: Fix completion after options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



the command specific complete callbacks only work when no
option is typed already. For example "devinfo <tab><tab>"
correctly completes the devices, but "devinfo -x <tab><tab>"
does nothing. That is because the options are passed to
the input string of the completion handlers. Skip the option
string by finding the last space in the input string. This
is not perfect since "devinfo -f<tab><tab>" still does not
work, but it's better than what we have now.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 common/complete.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/common/complete.c b/common/complete.c
index 9206ef0..368321f 100644
--- a/common/complete.c
+++ b/common/complete.c
@@ -277,11 +277,16 @@ static char* cmd_complete_lookup(struct string_list *sl, char *instr)
 	int len;
 	int ret = COMPLETE_END;
 	char *res = NULL;
+	char *t;
 
 	for_each_command(cmdtp) {
 		len = strlen(cmdtp->name);
 		if (!strncmp(instr, cmdtp->name, len) && instr[len] == ' ') {
 			instr += len + 1;
+			t = strrchr(instr, ' ');
+			if (t)
+				instr = t + 1;
+
 			if (cmdtp->complete) {
 				ret = cmdtp->complete(sl, instr);
 				res = instr;
-- 
2.0.0.rc0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux