Dash or Slash in batch file?

It seems that either a dash - or a slash / will work equally well in a batch file. The two examples below are equaly valid. Which is correct? Does it depend on the operation system? If so how do I determine which to use?

 shutdown -r -m \\server04 -t 01 -f 
 shutdown /r /m \\server04 /t 01 /f 

My goal is to write a batch file that will reach out to several windows severs and reboot them. The end result may also provide for pinging servers and allowing for user supplied choices on which servers to reboot. But my question is intended to define how to best format the code.

I found this related question on SO, which does not really provide an answer when to use one or the other. The question there got a lot of negativity for not being on Superuser. The majority of the opinions suggested that they used dash, but no solid rationale is given for using one over the other.


Solution 1:

Officially/traditionally in DOS/Windows the command-line switch is signified by a forward slash (/).

Officially/traditionally in practically all other OSs (for example: *nix flavors) they use a dash (-).

This is one of the fundamental differences between the way the OSs are designed and used.

Another (related) one, for example as Daniel B points out in his comment, a forward slash in *nix is for file path separators, where-as DOS/Windows uses backslashes -- another fundamental difference, which enables MS to (continue to) use the forward slash as the switch character.

But it's really up to the programmer to implement how they choose, and DOS/Windows application programmers (including those who work at MS) often include the ability to use either, for ease of use by people coming from other systems, and I'm sure often due to personal preference.

Programmers outside of MS sometimes omit allowing the use of the forward slash at all.

Good blurb:

It’s hard to imagine today, but the original version of Microsoft DOS — that’s MS-DOS 1.0 — didn’t support directories at all when it was released in 1981. Most of the utilities included with DOS were written by IBM, and they used the / character as a “switch” character

...

The different types of slashes here indicate whether you’re specifying an option or a directory path.

Blurb source: Why Windows Uses Backslashes and Everything Else Uses Forward Slashes