0

In linux bash there's a command command which can execute the "real" command even if you have a function name or a script filename that is named equal to that command.

function ping(){
    echo do nothing
}
command ping

will still work.

In windows batch, I have a file ping.cmd which goes into loop if I run ping inside of it.

What's the equivalent of command in windows batch?

1 Answers1

2

Answer 1: None, because Windows batch doesn't even have functions like bash does. It only has subroutines that use a different syntax than regular commands – ping vs call :ping – so there's no need for an override.

If you read the documentation more closely, command only skips aliases and functions, but does nothing about scripts in $PATH. In both shells, if you override using a real script file, it's up to you to find the "real" command.

Answer 2: To avoid the loop that you described, you'll need to specify the full name of "ping".

  • With bash, that would mean calling /bin/ping, or perhaps looping over $PATH until you find it.

  • On Windows, the same options exist; however, since your script is actually called ping.bat or ping.cmd, you can run ping.exe to avoid looping.

grawity
  • 501,077