doskey history behaviour across cmd instances
Posted: 31 Mar 2017 06:22
Npocmaka asked an interessting question SO: Why `cmd /k` and `cmd /c` remember the history of already finished cmd sub-processes?
The answer seems to be well-founded, but it doesn't explain some of the behaviour I saw in my experiments.
I don't understand the cause for the different output between Point1 and Point2.
If there is only one doskey instance at all, the output should be equal.
And why there is a difference between Point 3 and Point 4, the side of the pipe shouldn't affect the command at all
Point 3, Point5 should also be equal
But then I made one more experiment (just after the above tests)
Then I repeat the same sequence
Now the list for the cmd /c "doskey /history" is empty
But even better
There it's visible again
And this behaviour toggles for each
break | cmd /c "doskey /history"
any ideas out there
jeb
The answer seems to be well-founded, but it doesn't explain some of the behaviour I saw in my experiments.
Code: Select all
echo Main
cmd /k
echo sub1
echo sub2
doskey /history
exit
doskey /history
cmd /c "doskey /history"
doskey /history | more
break | doskey /history
cmd /c "doskey /history" | more
c:\Temp>echo Main
Main
c:\Temp>cmd /k
c:\Temp>echo sub1
sub1
c:\Temp>echo sub2
sub2
c:\Temp>doskey /history
echo sub1
echo sub2
doskey /history
c:\Temp>exit
c:\Temp>doskey /history ---- Point1
echo Main
cmd /k
doskey /history
c:\Temp>cmd /c "doskey /history" ---- Point2
echo sub1
echo sub2
doskey /history
exit
c:\Temp>
c:\Temp>doskey /history | more ---- Point3
echo Main
cmd /k
doskey /history
cmd /c "doskey /history"
doskey /history | more
c:\Temp>break | doskey /history ---- Point4
echo sub1
echo sub2
doskey /history
exit
c:\Temp>
c:\Temp>cmd /c "doskey /history" | more ---- Point5
echo sub1
echo sub2
doskey /history
exit
I don't understand the cause for the different output between Point1 and Point2.
If there is only one doskey instance at all, the output should be equal.
And why there is a difference between Point 3 and Point 4, the side of the pipe shouldn't affect the command at all
Point 3, Point5 should also be equal
But then I made one more experiment (just after the above tests)
Code: Select all
break | cmd /c "doskey /history"
cmd /c "doskey /history"
doskey /history | more
c:\Temp>break | cmd /c "doskey /history"
c:\Temp>cmd /c "doskey /history"
echo sub1
echo sub2
doskey /history
exit
c:\Temp>doskey /history | more
echo Main
cmd /k
doskey /history
cmd /c "doskey /history"
doskey /history | more
break | doskey /history
cmd /c "doskey /history" | more
break | cmd /c "doskey /history"
cmd /c "doskey /history"
doskey /history | more
Then I repeat the same sequence
Code: Select all
break | cmd /c "doskey /history"
cmd /c "doskey /history"
doskey /history | more
c:\Temp>break | cmd /c "doskey /history"
echo sub1
echo sub2
doskey /history
exit
c:\Temp>doskey /history
echo Main
cmd /k
doskey /history
cmd /c "doskey /history"
doskey /history | more
break | doskey /history
cmd /c "doskey /history" | more
break | cmd /c "doskey /history"
doskey /history
cmd /c "doskey /history"
break | cmd /c "doskey /history"
doskey /history
c:\Temp>cmd /c "doskey /history"
c:\Temp>
Now the list for the cmd /c "doskey /history" is empty
But even better
Code: Select all
break | cmd /c "doskey /history"
cmd /c "doskey /history"
There it's visible again
c:\Temp>break | cmd /c "doskey /history"
c:\Temp>cmd /c "doskey /history"
echo sub1
echo sub2
doskey /history
exit
And this behaviour toggles for each
break | cmd /c "doskey /history"
any ideas out there
jeb