From c3ef23b10f4c5bc5de7e685c631e6c5802dc4db0 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Mon, 20 Apr 2015 02:04:17 -0700 Subject: Support for a "pending item" in history. Before running a command, we add the command to history, so that if the command causes us to exit it's still captured in history. But that command should not be considered part of history when expanding the history within the command itself. For example, `echo $history[1]` should be the previously run command, not `echo $history[1]` itself. Fixes #2028 --- tests/generic.expect | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'tests/generic.expect') diff --git a/tests/generic.expect b/tests/generic.expect index d422603a..7a5b6407 100644 --- a/tests/generic.expect +++ b/tests/generic.expect @@ -11,3 +11,25 @@ send_line "echo " expect_prompt "" {} unmatched { puts stderr "Couldn't type apple key ()" } + +# check that history is returned in the right order (#2028) +# this hist_command nonsense is the cleanest way to send the $ char +set hist_command "echo \$history\[1\]" + +# first send 'echo stuff' +send_line "echo stuff" +expect_prompt "stuff" {} unmatched { + puts stderr "Couldn't find expected output 'stuff'" +} + +# last history item should be 'echo stuff' +send_line $hist_command +expect_prompt "echo stuff" {} unmatched { + puts stderr "Couldn't find expected output 'echo stuff'" +} + +# last history command should be the one that printed the history +send_line $hist_command +expect_prompt -re {echo .history.*} {} unmatched { + puts stderr "Couldn't find expected output $hist_command" +} -- cgit v1.2.3