The behaviour of HISTORY is in some aspects different from the descriptions in the helpfiles:
If you try - for example - to add echo %PATH to the history list, HISTORY /A echo %PATH will expand the %PATH varaible before adding it to the history list. Ctrl-K will add the original "echo %PATH" to the list.
Workaround: use backquotes around the command, like this:
In my opinion this is something the HISTORY command should take care of.
Furthermore, consider these two batchfiles:
(I had to add some delays because of timing issues)
In the first script there is a echo Hoi in the history list; in the second there is nothing, except when you quit the batch-file. Then it *is* on the history list....
Workaround: Couldn't find one.
And then there is the %@HISTORY function.
Don't try echo %@HISTORY[0]. It will cause a loop, because it will expand echo %@HISTORY[0] to echo echo %@HISTORY[0] ,etcetera.
Workaround: use "@" to prevent this command from being added to the history list, like this:
Or, if you want a certain sequence of commands to be re-executed:
/A Add a command to the history list. This performs the same function as the Ctrl-K key at the command line.
If you try - for example - to add echo %PATH to the history list, HISTORY /A echo %PATH will expand the %PATH varaible before adding it to the history list. Ctrl-K will add the original "echo %PATH" to the list.
Workaround: use backquotes around the command, like this:
Code:
HISTORY /A `echo %PATH`
In my opinion this is something the HISTORY command should take care of.
Furthermore, consider these two batchfiles:
Code:
@history /F
@history /A echo Hoi
@delay 1
@history
Code:
@history /F
@KEYSTACK /W3 "echo Hoi"
@delay 1
@KEYSTACK /W3 Ctrl-K
@delay 1
@history
In the first script there is a echo Hoi in the history list; in the second there is nothing, except when you quit the batch-file. Then it *is* on the history list....
Workaround: Couldn't find one.
And then there is the %@HISTORY function.
Don't try echo %@HISTORY[0]. It will cause a loop, because it will expand echo %@HISTORY[0] to echo echo %@HISTORY[0] ,etcetera.
Workaround: use "@" to prevent this command from being added to the history list, like this:
Code:
@echo %@HISTORY[0]
Or, if you want a certain sequence of commands to be re-executed:
Code:
DO nmbr = 12 to 7 BY -1
@%@HISTORY[%nmbr]
ENDDO
Last edited: