0

In a batch file I want to see if %1 is in a set.

E.g., as an alternative to

if %1 equ /? goto help
if /I %1 equ -? goto help
if /I %1 equ /help goto help
etc

It seems like it should be simple, but I can't make it work. I've tried with and without FOR loops and search:string.

1 Answer 1

1
@echo off
setlocal enabledelayedexpansion
set "helpoptions=@/?@-?@/help@"
if not "!helpoptions:@%~1@=!"=="%helpoptions%" goto help
goto :eof
:help
echo Help

would be an option, albeit not a very pretty one.

Sign up to request clarification or add additional context in comments.

1 Comment

Indeed. One can probably also use spaces as separators, which should reduce clutter, but may mask a few non-obviuos typos.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.