INPUT fails if the entered text contains pair of square brackets

sst

Aug 3, 2009
8
0
INPUT or SET /P fails if the entered text contains pair of square brackets.

Code:
[C:\]INPUT Enter text:  %%myvar
Enter text: Sample text [ to fail input ]
TCC: Not an array variable "myvar"

[C:\]

The documentation does not mention anything about this behavior so Its not clear to me if it is intentional or not.
The QUERYBOX command does not pose this limitation/behavior.

So is there any way to get such an input from stdin?
 

sst

Aug 3, 2009
8
0
In the meantime, I resorted to using this little snippet as a workaround for this limitation.
This may be useful to others who may use earlier versions of TCC which which may be affected by this bug.

It also has the advantage(for me) that the input history is available with CMD's SET /P, whereas TCC does not provide this functionality with SET /P and INPUT (or maybe I don't know how to activate it).

Code:
setlocal
    setdos /x0-45678
    unset userInput
    set "savedTitle=%_WINTITLE"
    (echos Prompt text goes here)
    setdos /x+5678
    REM The CMD's title command outputs the help message if the title matches this regex pattern "/\s*[?]"
    REM So it should be redirected to nul to be safe
    for /F "delims=" %%I in ('@"%_WINSYSDIR\cmd" /e:on /v:on /d /c title !savedTitle!^^^>nul^^^&set /p "userInput="^^^&if defined userInput echo(!userInput!') do (
        setdos /x-5678
        set "userInput=%%I"
    )
endlocal userInput


SideNote:
I had to omit the .exe extension from cmd because apparently the forum software does permit the post to contain cmd.exe. This does not occur with other names like TCC.exe. Strange!
 
Last edited:
May 20, 2008
11,400
99
Syracuse, NY, USA
And while it doesn't object to TCC.EXE, it does have a problem with TCMD‍.EXE ....
That's because it has a naughty substring. Charles, why did you choose character 8205 (0x200D) and how did you get it into your post? [Character 8205 is between the 'D' and the '.' in my quote from Charles's post.]

It might be done for a very simple reason ... security. I'm confident you could do some damage if you talked a user into executing the right CMD command line copied from the forum. And if it is done for the sake of security, it's pretty lame!
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
That's because it has a naughty substring. Charles, why did you choose character 8205 (0x200D) and how did you get it into your post? [Character 8205 is between the 'D' and the '.' in my quote from Charles's post.]

That's the zero-width joiner. Just a character which people can't see, but is sufficient to fool the filter. There are other Unicode characters which would work just as well.

As for how, I have a command COPYCHARS that lets me stick arbitrary characters on the clipboard: copychars "CMD" zwj; ".EXE"
But you can do the same trick with CharMap.
 
Last edited:
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Command Input Syntax Colouring Support 3
T Disable audible beep on input and inkey Support 2
T input accepts empty answer Support 5
WinLanEm INPUT problem Support 1
rps Command Input Window tab completion broken Support 7
D Documentation Using "send all input to other tabs" Support 11
J Input text converts to uppercase Support 1
B Select and run lines from Command Input panel? Support 1
Charles Dye TYPE /P behaves strangely with piped/redirected input Support 0
T command input font Support 2
ehab aboudaya How to? Command Input history for each tab? Support 0
M How to? How do I read a Unicode file through standard-input? Support 4
Joe Caverly How to? Function Key With INPUT Support 5
E Saving out Command Input window Support 4
J VIEW crash on redirected input and numbered bookmarks Support 6
J Keyboard input error Support 6
vefatica TCMD tabs and input focus Support 11
daniel347x Is it possible to send a line from the "command input" window to the tab without pressing "Enter", w Support 4
Stefano Piccardi how to @SELECT redirected input? Support 4
A GNU ed won't accept redirected input Support 0
G Command Input window Support 2
dcantor Suggestion for @DATE[] input Support 2
J Command line completion in the "Command Input" Window Support 3
Charles Dye INPUT prompt oddity Support 5
E Environment variables, set and input Support 2
samintz COPY fails to copy from \\wsl$ Support 20
M Goto fails when a text endtext block precedes the code Support 5
vefatica SETP usually fails with a 32 bit process Support 4
B Request Manual Key fails Support 3
L TCC V22 installer fails signature validation Support 0
A Fixed v25 regression: Parameter expansion fails in piped commands Support 2
vefatica START /PGM "name with spaces.URL" fails Support 2
I zip /M fails to delete file after adding to zip file Support 2
D skip= in FOR /F fails Support 9
Joe Caverly Using a Directory Alias with @iniwrite fails Support 14
A WAD Output redirection to IF block fails with "unbalanced brackets" Support 7
E My echo full file name to the clipboard fails now. Support 2
A Fixed (CMD compat) START /D fails to recognize the switch option. Support 3
B MKLINK requires admin - fails silently. Support 1
D Fixed Take Command 21.0.29 fails – MSVCP140.dll missed Support 6
F Powershell call fails with "Scripting Integrator 2016 (PowerShell)" license error Support 9
fishman@panix.com Version 21.23 fails to install Support 4
D unzip fails to find valid license Support 3
StarliteLemming Fileread fails on Unicode file Support 10
D Upgrade from 19 to 19.10 fails Support 2
C Upgrade to v19.10.42 fails Support 5
D V19 fails to install on Win7-64bit, installer says: Support 2
bervin Webform fails on HTTPS Support 1
thedave Windows 10: Pinned taskbar fails Support 20
P MS VS2013 vsdevcmd.bat fails to run with tcmd 17 x64 Support 10

Similar threads