when storing commands with embedded newlines, don’t take those as end of string
(inspired fix from Debian #783978; bug in original pdksh COMPLEX_HISTORY code)
This commit is contained in:
parent
b9a8fdf905
commit
b87215bbaf
12
histrap.c
12
histrap.c
@ -27,7 +27,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.143 2015/04/29 20:44:35 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.144 2015/07/05 16:47:28 tg Exp $");
|
||||||
|
|
||||||
Trap sigtraps[ksh_NSIG + 1];
|
Trap sigtraps[ksh_NSIG + 1];
|
||||||
static struct sigaction Sigact_ign;
|
static struct sigaction Sigact_ign;
|
||||||
@ -634,11 +634,13 @@ void
|
|||||||
histsave(int *lnp, const char *cmd, bool dowrite MKSH_A_UNUSED, bool ignoredups)
|
histsave(int *lnp, const char *cmd, bool dowrite MKSH_A_UNUSED, bool ignoredups)
|
||||||
{
|
{
|
||||||
char **hp;
|
char **hp;
|
||||||
char *c, *cp;
|
char *c;
|
||||||
|
const char *ccp;
|
||||||
|
|
||||||
strdupx(c, cmd, APERM);
|
ccp = cmd + strlen(cmd);
|
||||||
if ((cp = strchr(c, '\n')) != NULL)
|
while (ccp > cmd && ccp[-1] == '\n')
|
||||||
*cp = '\0';
|
--ccp;
|
||||||
|
strndupx(c, cmd, ccp - cmd, APERM);
|
||||||
|
|
||||||
if (ignoredups && !strcmp(c, *histptr)
|
if (ignoredups && !strcmp(c, *histptr)
|
||||||
#if !defined(MKSH_SMALL) && HAVE_PERSISTENT_HISTORY
|
#if !defined(MKSH_SMALL) && HAVE_PERSISTENT_HISTORY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user