diff options
author | vb160487 <none@none> | 2007-09-25 00:43:01 -0700 |
---|---|---|
committer | vb160487 <none@none> | 2007-09-25 00:43:01 -0700 |
commit | cd31838b5d981a4341d3522bb2b1dda71efd9fea (patch) | |
tree | d305f8c281aec0b15eeec1367407174f5caa8025 /usr/src | |
parent | adfcba552dfc70ff685a2e8703fe1761b244f3e8 (diff) | |
download | illumos-joyent-cd31838b5d981a4341d3522bb2b1dda71efd9fea.tar.gz |
5061885 '[' and ']' commands should not pollute the kmdb/mdb command history
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/mdb/common/mdb/mdb_cmdbuf.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmdbuf.c b/usr/src/cmd/mdb/common/mdb/mdb_cmdbuf.c index 696b396538..e452826367 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_cmdbuf.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_cmdbuf.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -167,13 +167,24 @@ const char * mdb_cmdbuf_accept(mdb_cmdbuf_t *cmd) { if (cmd->cmd_bufidx < cmd->cmd_linelen) { + int is_repeating = 0; + cmd->cmd_buf[cmd->cmd_buflen++] = '\0'; (void) strcpy(cmd->cmd_linebuf, cmd->cmd_buf); + if (cmd->cmd_hold != cmd->cmd_hnew) { + int lastidx = cmd->cmd_hnew == 0 ? cmd->cmd_halloc - 1 : + cmd->cmd_hnew - 1; + + is_repeating = strcmp(cmd->cmd_buf, + cmd->cmd_history[lastidx]) == 0; + } + /* - * Don't bother inserting empty buffers into the history ring. + * Don't bother inserting empty or repeating buffers into the + * history ring. */ - if (cmd->cmd_buflen > 1) { + if (cmd->cmd_buflen > 1 && !is_repeating) { cmd->cmd_hnew = (cmd->cmd_hnew + 1) % cmd->cmd_histlen; if (cmd->cmd_hnew >= cmd->cmd_halloc) mdb_cmdbuf_allocchunk(cmd); @@ -186,6 +197,8 @@ mdb_cmdbuf_accept(mdb_cmdbuf_t *cmd) (cmd->cmd_hold + 1) % cmd->cmd_histlen; else cmd->cmd_hlen++; + } else if (is_repeating) { + cmd->cmd_hcur = cmd->cmd_hnew; } cmd->cmd_bufidx = 0; |