Friday, May 13, 2005, 3:25 PM
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?!?
13 comments on this post
John Vert:
You can also set different console aliases for different exe's. See AddConsoleAlias.
Friday, May 13, 2005, 3:57 PM
Chris Sells:
Friday, May 13, 2005, 4:49 PM
Chris Sells:
Friday, May 13, 2005, 5:03 PM
Haacked:
You click happy mouse lover.
;)
Friday, May 13, 2005, 5:07 PM
Jason:
Friday, May 13, 2005, 9:48 PM
Joe Duffy:
I've also found that for multi-line source, you can get pretty efficient with the keystrokes to rerun a whole program. Say you have n lines of code... Well you [hit up n times, make changes, enter]... Repeat this sequence n times. My subconscious has become proficient in executing this task. :)
One thing we still need that most *NIX shells give you: ^a^b replacement. If you got that for free, I think we might just win the OS war.
Saturday, May 14, 2005, 8:32 AM
John:
Saturday, May 14, 2005, 10:28 AM
Dr Pizza:
And thank god it does. It means that (almost) all globbing can be deferred to the filesystem ('cos FSDs implement it... IIRC more than once), so it always gets done the same way, and, as an added bonus, it means that you can do things like easy bulk renames.
Monday, May 16, 2005, 2:39 AM
Ellery:
Monday, May 16, 2005, 10:40 PM
Richard:
progname "my single arg1" arg2
This is a real pain when you use an exec() variant in C (is that a POSIX thing?) and think you're passing in a nice array of args, only to get them munged into a single line and the called program having to parse them out again! EEEK! The below won't work as expected:
exec("myProg","Command One", "Command Two");
I'm afraid the UNIX shells had this a lot better by handling the responsibility for command parsing and globbing to the shell or other calling program.
In the case of the shell, it's the user choice which one is used and so which globbing style is used. Consistency is ensured.
In the case of a calling program you can safely pass arbitrary user input to a child process without having to worry about metacharacters getting in the way. In other words - it's a lot more secure.
I can say
MYVAR1=Hello; World " ' &
MYVAR2=Wibble oh more " funny chars
someCommand $MYVAR1 $MYVAR2
and expect it to work.
Unfortunately I don't think Microsoft can fix it. Too much existing code relies on the way the system currently works. Fortunately for Microsoft, they tend to use other mechanisms for scripting and calling child programs.
Where UNIX has optimised it's ability to fork() quickly and share process loading impact between instances, Microsoft have chosen other means. I thought Dot-Net and it's Global Assembly Cache was heading towards more UNIX-like code image sharing, but oh well.
Wednesday, May 18, 2005, 1:28 AM
dmbaxtw cybkrifp:
Saturday, Apr 21, 2007, 10:22 PM
ibngxcsz kotmenczx:
Saturday, Apr 21, 2007, 10:24 PM
mzcrhfvpq kpwntab:
Saturday, Apr 21, 2007, 10:24 PM




