Skip to contentSkip to conversation

command compleation in latest u-boot?

U-Boot-Users Joakim Tjernlund 4 participants 7 messages Nov 27, 2007 – Dec 22, 2007

lore
Share & tools
lore
#0 lore raw

Trying to move my boot to latest u-boot and I can't make command completion work. Does it work in current u-boot and what config options do you use?

Jocke

#1 lore raw

Hi Jocke,

Quoted 3 lines · Joakim Tjernlund

Trying to move my boot to latest u-boot and I can't make command completion work. Does it work in current u-boot and what config options do you use?

IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command history is my choice here.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#2 lore raw
Quoted 10 lines

-----Original Message-----
From: Stefan Roese [mailto:sr at denx.de]
Sent: den 27 november 2007 19:36
To: u-boot-users at lists.sourceforge.net
Cc: Joakim Tjernlund
Subject: Re: [U-Boot-Users] command compleation in latest u-boot?

Hi Jocke,

On Tuesday 27 November 2007, Joakim Tjernlund wrote:

Quoted 8 lines
Quoted 3 lines

Trying to move my boot to latest u-boot and I can't make command completion work. Does it work in current u-boot and what config options do you use?

IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command
history is my choice here.

Using both of them, but TAB still does not complete anything.

Jocke

#3 lore raw
In reply to Stefan Roese
Quoted 10 lines · Stefan Roese

Hi Jocke,

Quoted 3 lines · Joakim Tjernlund

Trying to move my boot to latest u-boot and I can't make command completion work. Does it work in current u-boot and what config options do you use?

IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command history is my choice here.

Ahh, I can only use one. In my old boot I can use both because I applied a patch from Pantelis that I thought was in uboot already. Can you have a look at Pantelis patch an apply if appropriate?

Here is the patch:
From:
Pantelis Antoniou
<[email protected]>

                                To: 
u-boot-users at lists.sourceforge.net
                                Cc: 

Frank Robbins
<[email protected]>,
Dan Malek <[email protected]>,
Wolfgang Denk <[email protected]>, Peter
Tympanick <[email protected]>
Subject:
[U-Boot-Users] [PATCH 1/8] Make
autocomplete work with HUSH parser
too.
Date:
Sun, 03 Dec 2006 00:15:50 +0200
(Sat, 23:15 CET)

Auto complete did not work when the HUSH parser was selected. Fix this obvious problem.

---

---

 README        |    4 ----
 common/main.c |   25 +++++++++++++++++++++++--
 2 files changed, 23 insertions(+), 6 deletions(-)
README +0 -4
index ecfd1f8..e28f935 100644
@@ -1511,10 +1511,6 @@ The following options need to be configured:
 
                Enable auto completion of commands using TAB.
 
-               Note that this feature has NOT been implemented yet
-               for the "hush" shell.
-
-
                CFG_HUSH_PARSER
 
                Define this variable to enable the "hush" shell (from
common/main.c +0 -0
index cc4b50f..a8ae07c 100644
@@ -718,10 +718,11 @@ static void cread_add_str(char *str, int strsize,

int insert, unsigned long *num

        }

}

-static int cread_line(char *buf, unsigned int *len)
+static int cread_line(const char *const prompt, char *buf, unsigned int *len)

 {
        unsigned long num = 0;
        unsigned long eol_num = 0;
+       int num2, col;
        unsigned long rlen;
        unsigned long wlen;
        char ichar;
@@ -840,6 +841,7 @@ static int cread_line(char *buf, unsigned int *len)
                        insert = !insert;
                        break;
                case CTL_CH('x'):
+               case CTL_CH('u'):       /* like that too */
                        BEGINNING_OF_LINE();
                        ERASE_TO_EOL();
                        break;
@@ -889,6 +891,25 @@ static int cread_line(char *buf, unsigned int *len)
                        REFRESH_TO_EOL();
                        continue;
                }

+#ifdef CONFIG_AUTO_COMPLETE
+ case '\t':
+
+ /* do not autocomplete when in the middle */
+ if (num < eol_num) {
+ getcmd_cbeep();
+ break;
+ }
+

+                       buf[num] = '\0';
+                       col = strlen(prompt) + eol_num;
+                       num2 = num;
+                       if (cmd_auto_complete(prompt, buf, &num2, &col))
{
+                               col = num2 - num;
+                               num += col;
+                               eol_num += col;

+ }
+ break;
+#endif
default:
cread_add_char(ichar, insert, &num, &eol_num,

buf, *len);
                        break;

@@ -931,7 +952,7 @@ int readline (const char *const prompt)

        puts (prompt);

- rc = cread_line(p, &len);

+       rc = cread_line(prompt, p, &len);
        return rc < 0 ? rc : len;
 #else
        char   *p = console_buffer;
#4 lore raw
Quoted 7 lines · Joakim Tjernlund
Quoted 3 lines

IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command history is my choice here.

Ahh, I can only use one. In my old boot I can use both because I applied a patch from Pantelis that I thought was in uboot already. Can you have a look at Pantelis patch an apply if appropriate?

Yes, would be good if both is possible. Could you do me a favor and redo this patch against the current source code. Also it seems that this will trigger some compile warning for unused variables "num2, col" when CONFIG_AUTO_COMPLETE is not defined. Please check and resend a fixed version and I'll make sure that it gets applied when the next merge window opens.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================

#5 lore raw
Quoted 9 lines · Stefan Roese
Quoted 7 lines · Joakim Tjernlund
Quoted 3 lines

IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command history is my choice here.

Ahh, I can only use one. In my old boot I can use both because I applied a patch from Pantelis that I thought was in uboot already. Can you have a look at Pantelis patch an apply if appropriate?

Quoted 6 lines

Yes, would be good if both is possible. Could you do me a favor and redo this patch against the current source code. Also it seems that this will trigger some compile warning for unused variables "num2, col" when CONFIG_AUTO_COMPLETE is not defined. Please check and resend a fixed version and I'll make sure that it gets applied when the next merge window opens.

the patch posted still applies cleanly (ignoring offsets and the crappy word wrapping). for sake of completeness, ive attached patch against current mainline git after giving it a spin against a recent version. -mike

common/main.c +24 -2
index 379695c..4253eac 100644
@@ -696,7 +696,7 @@ static void cread_add_str(char *str, int strsize, int insert, unsigned long *num
 	}
 }
 
-static int cread_line(char *buf, unsigned int *len)
+static int cread_line(const char *const prompt, char *buf, unsigned int *len)
 {
 	unsigned long num = 0;
 	unsigned long eol_num = 0;
@@ -818,6 +818,7 @@ static int cread_line(char *buf, unsigned int *len)
 			insert = !insert;
 			break;
 		case CTL_CH('x'):
+		case CTL_CH('u'):
 			BEGINNING_OF_LINE();
 			ERASE_TO_EOL();
 			break;
@@ -867,6 +868,27 @@ static int cread_line(char *buf, unsigned int *len)
 			REFRESH_TO_EOL();
 			continue;
 		}
+#ifdef CONFIG_AUTO_COMPLETE
+		case '\t': {
+			int num2, col;
+
+			/* do not autocomplete when in the middle */
+			if (num < eol_num) {
+				getcmd_cbeep();
+				break;
+			}
+
+			buf[num] = '\0';
+			col = strlen(prompt) + eol_num;
+			num2 = num;
+			if (cmd_auto_complete(prompt, buf, &num2, &col)) {
+				col = num2 - num;
+				num += col;
+				eol_num += col;
+			}
+			break;
+		}
+#endif
 		default:
 			cread_add_char(ichar, insert, &num, &eol_num, buf, *len);
 			break;
@@ -909,7 +931,7 @@ int readline (const char *const prompt)
 
 	puts (prompt);
 
-	rc = cread_line(p, &len);
+	rc = cread_line(prompt, p, &len);
 	return rc < 0 ? rc : len;
 #else
 	char   *p = console_buffer;
#6 lore raw
Quoted 17 lines · Mike Frysinger
Quoted 9 lines · Stefan Roese
Quoted 7 lines · Joakim Tjernlund
Quoted 3 lines

IIRC, then you have to choose to enable either command completion (CONFIG_AUTO_COMPLETE) or command history (CONFIG_CMDLINE_EDITING). Command history is my choice here.

Ahh, I can only use one. In my old boot I can use both because I applied a patch from Pantelis that I thought was in uboot already. Can you have a look at Pantelis patch an apply if appropriate?

Quoted 6 lines

Yes, would be good if both is possible. Could you do me a favor and redo this patch against the current source code. Also it seems that this will trigger some compile warning for unused variables "num2, col" when CONFIG_AUTO_COMPLETE is not defined. Please check and resend a fixed version and I'll make sure that it gets applied when the next merge window opens.

Quoted 5 lines

the patch posted still applies cleanly (ignoring offsets and the crappy word wrapping). for sake of completeness, ive attached patch against current mainline git after giving it a spin against a recent version. -mike

Add in ixp repository on testing branch

Best Regards,
J.