A generic SET /P question

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

A generic SET /P question

#1 Post by timbertuck » 12 Oct 2012 11:47

can someone explain what is happening
i can run this line
set /p Ques1=What is the question ?
and this one
set /p Ques1=What is the question ? /
as well as
set /p Ques1=What is the question ^? ^/
but not this
set /p Ques1=What is the question ^/ ^?
or this
set /p Ques1=What is the question / ?

when set /p see's a slash (and escaped as well) and then a question mark, it behaves like:
set /?

im trying to use it like so
set /p Ques1=What is your input [A/D/K/M/?] ^<D^>
but even escaping it does not work.
set /p Ques1=What is your input [A/D/K/M^/^?] ^<D^>

now the obvious workaround is to either put the ? in front of the slash or switch the slash for a comma or a dash or a backslash but im just curious as to the why SET behaves this way.

tt

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: A generic SET /P question

#2 Post by Squashman » 12 Oct 2012 11:59

Code: Select all

set /p "Ques1=What is your input [A/D/K/M/?] <D>"

timbertuck
Posts: 76
Joined: 21 Dec 2011 14:21

Re: A generic SET /P question

#3 Post by timbertuck » 12 Oct 2012 12:54

Squashman wrote:

Code: Select all

set /p "Ques1=What is your input [A/D/K/M/?] <D>"


Thanks S for that additional solution!

but that still doesn't answer the OP though? which is why does text, ^slash and then the ^question mark make SET loose it's mind and forget about the prompt before the escaped "slash" and "?", and act as though you had typed "SET /?"

is that as the programmers intended it to behave?

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: A generic SET /P question

#4 Post by Squashman » 12 Oct 2012 13:52

I could be wrong but I thought some one did a write up on SET /P a while back. I just know that putting the quotes in there preserves the special characters. So in essence if you are not preserving the special characters I would think that the SET command sees the /? as a command line argument.

Post Reply