Search found 893 matches

by jeb
11 Feb 2019 05:19
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 302

Re: Call and goto may fail when the batch file has Unix line endings

One more observation. As you already said, the scan for labels is reset at the file beginning or after a CR/LF. The label scanner reads chunks of ~512 bytes, therefore we see the described effect. BUT the scanner is able to set the new file position to the wrong position after a label is found :!: @...
by jeb
11 Feb 2019 04:49
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 302

Re: Call and goto may fail when the batch file has Unix line endings

Thanks Dave, your findings are impressive :D. I didn't see the idea of relative counting the characters :( I played with a file with unix style endings and a single CR/LF and thought the problem was gone as I didn't see the reset behaviour. But your analysis is really good. And your rule is really s...
by jeb
09 Feb 2019 12:47
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 302

Re: Call and goto may fail when the batch file has Unix line endings

Hi jfl, like Dave I'm very interessted. And I simplified your code to a minimal, failing example: @echo off goto :zwei :####################################################################################################################################################################################...
by jeb
06 Feb 2019 09:29
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 250

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi jfl, nice work! Eventually I found a heuristic that seems to give good results: - If the first token is == %COMSPEC% without quotes, then this is a for /f, and I should not run AutoRun scripts. - If the second token is /c, then this a manual execution of a single command, and it's not worth runni...
by jeb
05 Feb 2019 02:24
Forum: DOS Batch Forum
Topic: I need to escape pipe character in a string but still remove leading and trailing quotes
Replies: 6
Views: 122

Re: I need to escape pipe character in a string but still remove leading and trailing quotes

Hi bosekamineni, you should use delayed expansion, because it's always safe to expand with delayed expansion. @echo off setlocal EnableDelayedExpansion set "_string=Test String With | &&<> command" echo the string is !_string! The only drawback is that you be careful with literal exclamation marks, ...
by jeb
28 Jan 2019 03:01
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 250

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi siberia-man, - It is reliable to detect an invocation from FOR/F. - Invokations from pipes doesn't trigger the autostart at all. - When a new instance of cmd.exe is launched directly it can fail, as it's possible to add any possible parameter, but then it only drops the additional commands. It sh...
by jeb
28 Jan 2019 01:48
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 250

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi, I'm using the registry key to start a batch file, that adds some doskey macros. BUT it's a bit tricky, as the batch file will also be called for new cmd instances inovked by FOR /F :!: If the batch file doesn't check that, you can get really strange behaviour in all of your batch files. Think of...
by jeb
25 Jan 2019 13:45
Forum: DOS Batch Forum
Topic: doskey output can't always be captured
Replies: 3
Views: 136

Re: doskey output can't always be captured

Hi jfl, interesting :) I tried to build a simple workaround history.bat @echo off doskey /history | findstr /n "^" It works as expected 1:doskey /history 2:echo test 3:npp hist.bat 4:hist .. and I thought that the output of the findstr should work normal, but ... history.bat | more Still outputs not...
by jeb
21 Dec 2018 08:31
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 807

Re: Directly reading from pipe by the parent CMD process

Hi Dave, I tested your code Windows 7 x64: 4096 Windows XP x32: 4096, but FINDSTR doesn't work reliable And I retested the blocking limit of pipe blocks. First a testString of the configured size is send. The a "second line" is send. If the blocking is active the second line is send only when thread...
by jeb
06 Dec 2018 05:57
Forum: DOS Batch Forum
Topic: Ampersand is directory name - Batch not working
Replies: 2
Views: 174

Re: Ampersand is directory name - Batch not working

Hi Andreas, I suppose there is more in your batch file, because I just tested this sample batch file in a directory named "C:\temp\amp & ersand\" and it works @echo off setlocal EnableDelayedExpansion echo cmdcmdline: !cmdcmdline! start "Firefox" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" ...
by jeb
13 Nov 2018 00:45
Forum: DOS Batch Forum
Topic: Writing Batch code in an easier way with the aid of macros
Replies: 16
Views: 2403

Re: Writing Batch code in an easier way with the aid of macros

Hi siberia-man, I currently can't follow Aacini's technic :?: , but it looks impressive ( I have to spend more time on this). But I can answer your question. A quite exciting technique for scripting batch macros. One this I can't understand. When you code the beginning of any macro you use something...
by jeb
13 Nov 2018 00:36
Forum: DOS Batch Forum
Topic: Strange behaviour with ansi sequence
Replies: 3
Views: 334

Re: Strange behaviour with ansi sequence

Hi J'aitreschaud, ESC[ <n> m is the Select Graphic Rendition sequence, it sets the display attributes, they affect each NEW character that will be written, that's all. In your case, it changes the complete background after the cls, as the complete screen will be filled with spaces. To reset that set...
by jeb
04 Nov 2018 13:51
Forum: DOS Batch Forum
Topic: call expands variables / parameters differently with double percent signs
Replies: 1
Views: 315

Re: call expands variables / parameters differently with double percent signs

Hi pieh-ejdsch, Then with a double circumflex final. The parameters are passed into the :Sub but with circumflex at the end these parameters expand to a rat tail. The caret/circumflex will be doubled always by a CALL command, normally this isn't visible, as the doubled carets are used as escape char...
by jeb
29 Sep 2018 09:30
Forum: DOS Batch Forum
Topic: Source code for MS-DOS v1.25 and v2.0
Replies: 2
Views: 1127

Source code for MS-DOS v1.25 and v2.0

Hi,

today Microsoft published MS-Dos v1.25 and v2.0 as Open Source at github

jeb
by jeb
18 Sep 2018 02:52
Forum: DOS Batch Forum
Topic: How to detect if input comes from pipe or redirected file
Replies: 9
Views: 3434

Re: How to detect if input comes from pipe or redirected file

I used an extra test script, my main script has the name detectRedirect.bat @echo off call detectRedirect.bat #1 stdout_default call detectRedirect.bat #2 stdout2Nul > nul call detectRedirect.bat #3 stderr2Nul 2> nul call detectRedirect.bat #4 both2Nul 1> nul 2> nul #1 stdout_default STDOUT = 0 STDE...