Skip to contentSkip to conversation

common: Fix autocompletion with CONFIG_CMDLINE_PS_SUPPORT

PATCH New Marek Vasut 2 participants 2 messages Jun 26, 2019 – Jul 18, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common: Fix autocompletion with CONFIG_CMDLINE_PS_SUPPORT

The autocompletion did not work if CONFIG_CMDLINE_PS_SUPPORT was enabled because U-Boot was comparing the prompt string with CONFIG_SYS_PROMPT . While this works if CONFIG_CMDLINE_PS_SUPPORT is disabled, this no longer works if it's enabled because user can override the PS1 . Fix this by checking prompt string against the current PS1 value.

---
 common/command.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/command.c +6 -1
index e192bb2a61..db25bf54e0 100644
@@ -356,8 +356,13 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp)
 	int i, j, k, len, seplen, argc;
 	int cnt;
 	char last_char;
+#ifdef CONFIG_CMDLINE_PS_SUPPORT
+	const char *ps_prompt = env_get("PS1");
+#else
+	const char *ps_prompt = CONFIG_SYS_PROMPT;
+#endif
 
-	if (strcmp(prompt, CONFIG_SYS_PROMPT) != 0)
+	if (strcmp(prompt, ps_prompt) != 0)
 		return 0;	/* not in normal console */
 
 	cnt = strlen(buf);
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 common: Fix autocompletion with CONFIG_CMDLINE_PS_SUPPORT

Quoted 8 lines · Marek Vasut

The autocompletion did not work if CONFIG_CMDLINE_PS_SUPPORT was enabled because U-Boot was comparing the prompt string with CONFIG_SYS_PROMPT . While this works if CONFIG_CMDLINE_PS_SUPPORT is disabled, this no longer works if it's enabled because user can override the PS1 . Fix this by checking prompt string against the current PS1 value.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190718/d98a7d3d/attachment.sig>