I have written a batch script that prompts the user for an input and displays the help for a specific library ExternalLibrary
. However, I receive the error below the code sample.
@echo off
set input=NUL
set /p input="Help: "
python -c "import sys; sys.path.append('D:\\lib'); import ExternalLibrary;lookup = ExternalLibrary.Presentation_control();if ('%input%' == 'NUL'):& help(lookup.%input%)&else:& help(lookup)"
A working version can be achieved by replacing the if
statement with:
help(lookup.%input%)
Error in the column that starts with if
C:\Users\usah>Lib_Help.cmd
Help:
File "<string>", line 1
import sys; sys.path.append('D:\\lib'); import ExternalLibrary;lookup = ExternalLibrary.Presentation_control();if ('NUL' == 'NUL'):& help(lookup.NU
L)&else:& help(lookup)
^
SyntaxError: invalid syntax
Footnotes
1. I am note sure whether I should pass &
, \n
, or ;
as newline
2. These related answers are not satisfying as they use workarounds.