1

In my Linux development environment I have become accustomed to building and deploying my code in one line commands, for example:

mvn clean package && ./deploy.sh localhost

I have written bash aliases that simplify this process, in my environment the above would be aliased as:

mvncp && deploy

I am now working in a Windows development environment, so I run commands in a very similar way:

mvn clean package && deploy.bat localhost

To replace my aliases I have created doskey macros. Executing a macro by itself works just fine, however when I try to execute multiple macros chained together with && all macros after the first fail to be recognized.

mvncp && deploy
<output omitted>
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.588 s
[INFO] Finished at: 2014-10-13T10:38:36-06:00
[INFO] Final Memory: 31M/209M
[INFO] ------------------------------------------------------------------------
'deploy' is not recognized as an internal or external command,
operable program or batch file.

Sometimes cmd reports the macro could not be found, other times it silently fails and %errorlevel% returns 0.

Is there any way I can execute multiple doskey macros as a single command in cmd?

Vander Rice
  • 161
  • 1
  • 10
  • 1
    It won't help you here, but just to clarify: in windows `&`means "and then", `&&` means "and if successful, then". (to be complete: `||` would be "and if unsuccessful then") – Stephan Oct 13 '14 at 17:02

1 Answers1

3

The token you seek is $T

From https://en.wikipedia.org/wiki/DOSKEY

$T Command separator. Allows multiple commands in a macro.

Markus Jevring
  • 832
  • 1
  • 11
  • 17
  • I use it just you, in conjunction with my maven build and it works great. – Markus Jevring Nov 20 '14 at 09:18
  • It's too bad DOSKEY doesn't recognize it's own macros.. wish I could build a macro from existing macros. Alas, this gets the job done. Thanks! – Vander Rice Nov 21 '14 at 22:54
  • 3
    According to https://stackoverflow.com/questions/25044721/using-doskey-to-spawn-multiple-instances-of-explorer it's apparently also possible to escape the & using ^. It seems like ^&^& really lets you do conditional execution. – Markus Jevring Dec 18 '14 at 08:19