May 13, 2005 tools

When did the cmd shell start doing this?!?

Imagine the following C program:

// cmdio.c
#include <stdio.h>
void main() {
char s[256] = "";
printf(">");
scanf("%s", s);
printf("%s\n", s);
}

If I run this from a command shell and I enter hi” [Enter], it looks like this:

C:\>cmdio.exe
>hi
hi

If I run it again using lo” [Enter] this time, it would look like this:

C:\>cmdio.exe
>lo
lo

Here’s the thing that blew me away. Anytime I run it after the 1st from the same cmd shell, I get history! For example, running it a 3rd time and pressing [Up Arrow][Enter] gives me this!

C:\>cmdio.exe
>lo
lo

The up and down arrows work, F7 works, F8 works, they all work! When the heck did the shell start keeping track of per sub-command histories and why haven’t I noticed it til now?!?