V
V
Vova2017-03-22 17:21:39
cmd/bat
Vova, 2017-03-22 17:21:39

What does the strange entry in the cmd file mean?

Hello!
I found something strange in the file some.cmd:
(the name of the script was given from the bullshit).

if -%1-==-- (
  echo Error!!
  exit 1
)

what is this??!
I guess %1 is the first parameter when calling the script. But I could not identify the minuses and equalities.
Yes, we are talking about windows.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vova, 2017-03-23
@JustMoose

Found:
https://superuser.com/questions/948204/what-does-h...
Quote from the same link: "Generally, it is better to use conventional approaches that more people will more immediately understand" :))

R
res2001, 2017-03-22
@res2001

Everything is very simple - imagine what will happen if you do not specify the first parameter when running the script?
There will be a syntax error. Framing minuses are needed so that there is no mistake. But it's more correct to use quotes for this purpose: if "%1" equ ""

O
Olgeir, 2017-03-23
@Olgeir

Yes, this is a check that the first parameter is not empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question