Backticks and exit status on Windows

S

Skye Shaw!@#$

C:\>badcmd
'badcmd' is not recognized as an internal or external command,
operable program or batch file.

C:\>echo %errorlevel%
9009

C:\>ruby -ve"%x|badcmd 2>&1|; p $?.exitstatus"
ruby 1.9.3p429 (2013-05-15) [i386-mingw32]
1

C:\>ruby -ve"%x|ruby -e'exit 1'|; p $?.exitstatus"
ruby 1.9.3p429 (2013-05-15) [i386-mingw32]
1

When using backticks on Windows how does one differentiate between a process exit status of 1 and a command not being found? (Note that Errno::ENOENT is not raised when output is redirected).

This is not a problem in *nix boxes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top