tools: Only add unique entries to readline history
Luiz Augusto von Dentz
maintainerPATCH 1/1 tools: Only add unique entries to readline history
From: Luiz Augusto von Dentz <[email protected]>
Don't add duplicate commands to historym this is similar to what HISTCONTROL=ignoredups does.
--- client/main.c | 3 ++- tools/bluetooth-player.c | 4 +++- tools/btmgmt.c | 3 ++- tools/obex-client-tool.c | 3 ++- tools/obexctl.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-)
client/main.c +2 -1
@@ -2644,7 +2644,8 @@ static void rl_handler(char *input)if (!rl_release_prompt (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input); cmd =strtok_r (input," " , &arg);if (!cmd)
tools/bluetooth-player.c +3 -1
@@ -1086,7 +1086,9 @@ static void rl_handler(char *input) goto done;g_strstrip (input); -add_history (input); + +if (history_search (input,-1 )) +add_history (input); argv =g_strsplit (input," " ,-1 );if (argv ==NULL )
tools/btmgmt.c +2 -1
@@ -4664,7 +4664,8 @@ static void rl_handler(char *input)if (prompt_input (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;
tools/obex-client-tool.c +2 -1
@@ -242,7 +242,8 @@ static void parse_line(char *line_read)return ; } -add_history (line_read); +if (history_search (input,-1 )) +add_history (input);g_shell_parse_argv (line_read, &argcp, &argvp,NULL );
tools/obexctl.c +2 -1
@@ -2081,7 +2081,8 @@ static void rl_handler(char *input)if (!strlen (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;
Signature · 1 line
2.13.5
Hi Luiz,
Quoted 17 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Don't add duplicate commands to historym this is similar to what HISTCONTROL=ignoredups does.
--- client/main.c | 3 ++- tools/bluetooth-player.c | 4 +++- tools/btmgmt.c | 3 ++- tools/obex-client-tool.c | 3 ++- tools/obexctl.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-)client/main.c +0
-0
client/main.c static void rl_handler(char *input) · line 2649
Quoted 7 lines
client/main.c +2
-1@@ -2644,7 +2644,8 @@ static void rl_handler(char *input)if (!rl_release_prompt (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);
I think it is better to add g_strstrip(), since this patch adds a command typed all characters to history and then adds the complemented command to history when it have white-space.
Quoted 36 lines
client/main.c +0
-0cmd =strtok_r (input," " , &arg);if (!cmd)tools/bluetooth-player.c +3
-1@@ -1086,7 +1086,9 @@ static void rl_handler(char *input) goto done;g_strstrip (input); -add_history (input); + +if (history_search (input,-1 )) +add_history (input); argv =g_strsplit (input," " ,-1 );if (argv ==NULL )tools/btmgmt.c +2
-1@@ -4664,7 +4664,8 @@ static void rl_handler(char *input)if (prompt_input (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;tools/obex-client-tool.c +0
-0
tools/obex-client-tool.c static void parse_line(char *line_read) · line 246
Quoted 6 lines
tools/obex-client-tool.c +2
-1@@ -242,7 +242,8 @@ static void parse_line(char *line_read)return ; } -add_history (line_read); +if (history_search (input,-1 )) +add_history (input);
line_read is correct.
Quoted 9 lines
tools/obex-client-tool.c +0
-0g_shell_parse_argv (line_read, &argcp, &argvp,NULL );tools/obexctl.c +0
-0
tools/obexctl.c static void rl_handler(char *input) · line 2088
Quoted 9 lines
tools/obexctl.c +2
-1@@ -2081,7 +2081,8 @@ static void rl_handler(char *input)if (!strlen (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;
Regards,
Eramoto
Luiz Augusto von Dentz
maintainerHi Eramoto,
Quoted 23 lines · ERAMOTO Masaya
Hi Luiz,
Quoted 20 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Don't add duplicate commands to historym this is similar to what HISTCONTROL=ignoredups does.
--- client/main.c | 3 ++- tools/bluetooth-player.c | 4 +++- tools/btmgmt.c | 3 ++- tools/obex-client-tool.c | 3 ++- tools/obexctl.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-)client/main.c +0
-0@@ -2644,7 +2644,8 @@ static void rl_handler(char *input)if (!rl_release_prompt (input)) goto done;
Quoted 8 lines
client/main.c static void rl_handler(char *input) · line 2649
Quoted 4 lines
client/main.c +2
-1-add_history (input); +if (history_search (input,-1 )) +add_history (input);I think it is better to add
g_strstrip(), since this patch adds a command typed all characters to history and then adds the complemented command to history when it have white-space.
Yep, but as a separate change, this part of handling should really go into a common code so we don't have to keep duplicating this on every tool.
Quoted 39 lines
Quoted 39 lines
client/main.c +0
-0cmd =strtok_r (input," " , &arg);if (!cmd)tools/bluetooth-player.c +3
-1@@ -1086,7 +1086,9 @@ static void rl_handler(char *input) goto done;g_strstrip (input); -add_history (input); + +if (history_search (input,-1 )) +add_history (input); argv =g_strsplit (input," " ,-1 );if (argv ==NULL )tools/btmgmt.c +2
-1@@ -4664,7 +4664,8 @@ static void rl_handler(char *input)if (prompt_input (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;tools/obex-client-tool.c +0
-0@@ -242,7 +242,8 @@ static void parse_line(char *line_read)return ; }
Quoted 5 lines
tools/obex-client-tool.c static void parse_line(char *line_read) · line 246
Quoted 3 lines
tools/obex-client-tool.c +2
-1-add_history (line_read); +if (history_search (input,-1 )) +add_history (input);
line_readis correct.
Good catch, will fix it.
Quoted 23 lines
Quoted 9 lines
tools/obex-client-tool.c +0
-0g_shell_parse_argv (line_read, &argcp, &argvp,NULL );tools/obexctl.c +0
-0tools/obexctl.c static void rl_handler(char *input) · line 2088
Quoted 9 lines
tools/obexctl.c +2
-1@@ -2081,7 +2081,8 @@ static void rl_handler(char *input)if (!strlen (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;Regards,
Eramoto
Signature · 1 line
Luiz Augusto von Dentz
Hi,
Quoted 79 lines · Luiz Augusto von Dentz
Hi Eramoto,
Quoted 23 lines · ERAMOTO Masaya
Hi Luiz,
Quoted 20 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
Don't add duplicate commands to historym this is similar to what HISTCONTROL=ignoredups does.
--- client/main.c | 3 ++- tools/bluetooth-player.c | 4 +++- tools/btmgmt.c | 3 ++- tools/obex-client-tool.c | 3 ++- tools/obexctl.c | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-)client/main.c +0
-0@@ -2644,7 +2644,8 @@ static void rl_handler(char *input)if (!rl_release_prompt (input)) goto done;Quoted 8 lines
client/main.c static void rl_handler(char *input) · line 2649
Quoted 4 lines
client/main.c +2
-1-add_history (input); +if (history_search (input,-1 )) +add_history (input);I think it is better to add
g_strstrip(), since this patch adds a command typed all characters to history and then adds the complemented command to history when it have white-space.Yep, but as a separate change, this part of handling should really go into a common code so we don't have to keep duplicating this on every tool.
Quoted 39 lines
Quoted 39 lines
client/main.c +0
-0cmd =strtok_r (input," " , &arg);if (!cmd)tools/bluetooth-player.c +3
-1@@ -1086,7 +1086,9 @@ static void rl_handler(char *input) goto done;g_strstrip (input); -add_history (input); + +if (history_search (input,-1 )) +add_history (input); argv =g_strsplit (input," " ,-1 );if (argv ==NULL )tools/btmgmt.c +2
-1@@ -4664,7 +4664,8 @@ static void rl_handler(char *input)if (prompt_input (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;tools/obex-client-tool.c +0
-0@@ -242,7 +242,8 @@ static void parse_line(char *line_read)return ; }
Quoted 31 lines
Quoted 5 lines
tools/obex-client-tool.c static void parse_line(char *line_read) · line 246
Quoted 3 lines
tools/obex-client-tool.c +2
-1-add_history (line_read); +if (history_search (input,-1 )) +add_history (input);
line_readis correct.Good catch, will fix it.
Quoted 23 lines
Quoted 9 lines
tools/obex-client-tool.c +0
-0g_shell_parse_argv (line_read, &argcp, &argvp,NULL );tools/obexctl.c +0
-0tools/obexctl.c static void rl_handler(char *input) · line 2088
Quoted 9 lines
tools/obexctl.c +2
-1@@ -2081,7 +2081,8 @@ static void rl_handler(char *input)if (!strlen (input)) goto done; -add_history (input); +if (history_search (input,-1 )) +add_history (input);if (wordexp (input, &w,WRDE_NOCMD )) goto done;Regards,
Eramoto
Applied.
Signature · 1 line
Luiz Augusto von Dentz