Search found 31 matches

by lockedscope
22 Jun 2020 10:06
Forum: DOS Batch Forum
Topic: caret removes the first command after opening parenthesis if its concat'd to the first token of command without space
Replies: 4
Views: 4862

Re: caret removes the first command after opening parenthesis if its concat'd to the first token of command without spac

As a workaround, following works with a label operator(: colon) before the line wherever `commands first token splitting caret` usage appears (: di^ r t*.cmd echo b) The rule applies at any line so we need to fix it before every line such a weird caret usage appears (: di^ r t*.cmd echo a : di^ r t*...
by lockedscope
21 Jun 2020 06:32
Forum: DOS Batch Forum
Topic: caret removes the first command after opening parenthesis if its concat'd to the first token of command without space
Replies: 4
Views: 4862

caret removes the first command after opening parenthesis if its concat'd to the first token of command without space

- Following works because there is space after the first token of command ( dir ^ t*.cmd ) - Following removes the first command because of caret is in first token and echo works ( di^ r t*.cmd echo abc ) 'r' is not recognized as an internal or external command, operable program or batch file. abc -...
by lockedscope
19 Jun 2020 10:18
Forum: DOS Batch Forum
Topic: Pass multiple lines(through stdin) from batch to powershell
Replies: 4
Views: 5900

Re: Pass multiple lines(through stdin) from batch to powershell

Actually echo works fine when writing multiline string to output or redirecting output to file but it does not when piping. But it is not related to piping itself because commands like "type" could pipe multiline string to "for..findstr". So, string is in parenthesis with echo command as its argumen...
by lockedscope
18 Jun 2020 11:52
Forum: DOS Batch Forum
Topic: Pass multiple lines(through stdin) from batch to powershell
Replies: 4
Views: 5900

Re: Pass multiple lines(through stdin) from batch to powershell

It works, thanks Try: ( echo abc echo exit ) | Powershell.exe -Noprofile -File test.ps1 Antonio So insights from you, i remembered the alternative new line and it worked too set \n=^&echo. echo abc!\n!xyz!\n! | openssl base64 echo abc%\n%exit1%\n% | Powershell.exe -Noprofile -File test.ps1 echo abc!...
by lockedscope
18 Jun 2020 11:30
Forum: DOS Batch Forum
Topic: Pass multiple lines(through stdin) from batch to powershell
Replies: 4
Views: 5900

Pass multiple lines(through stdin) from batch to powershell

In the following i try to pass multi-line string to powershell or a powershell script(test.ps1) but it does not work. Echo multi-line string does not work, but typing multi-line file works. Why, how could i achieve it with echo? :?: setlocal enableDelayedExpansion (set \n=^ %=DONT REMOVE THIS=% ) fo...
by lockedscope
16 Jun 2020 04:28
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 4593

Re: How batch parsing phases work?

Thanks jeb, set b is a good advice, i was also on it. So, when we assign without quotes set "a=^^^^^^^!text^^^^^^^!" - So, a=^^^!text^^^! set b=%a% For set b=%a%; phase 2, converts ^^^!text!^^^ to ^!text!^ phase 5, convert ^!text!^ to !text! phase 7, execute command, !text! is assigned literally to ...
by lockedscope
15 Jun 2020 09:42
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 4593

Re: How batch parsing phases work?

After jeb's explanation of phases, i grasped it now (not all rules :lol: ). EXPANSION - In 1. percent expansion phase, %b% expands to ^^^!text!^^^ CARET RESOLVING - In 2. special characters phase, we encounter carets so resolve them, 1. and 3. carets removed on both sides so we have ^!text!^ literal...
by lockedscope
15 Jun 2020 08:06
Forum: DOS Batch Forum
Topic: How delayed expansion works?
Replies: 3
Views: 4009

Re: How delayed expansion works?

Thanks jeb
jeb wrote:
13 Jun 2020 10:31
Hi lockedscope,

yes your eplanation is correct.
Percent expansion is always the first one and can't be suppressed.
Then the for-variables expansion occurs.
And the last expansion can be the delayed expansion, if enabled.

jeb
by lockedscope
15 Jun 2020 07:47
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 5960

Re: Dynamic loop code over multiple lines causes extra quotes

Hi jeb, thanks :wink: :wink: ,

that's very obvious now, i am already trying to understand phases. It is gorgeous how you could find out all those phases, very good job.
by lockedscope
15 Jun 2020 07:37
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 4593

How batch parsing phases work?

I have following interpretation of phases. Is "set "c=%b%"" explanation correct? :?: rem @echo off setlocal enableDelayedExpansion set text=my set "a=^^^^^^^!text^^^^^^^!" echo "a: %a%" rem echo "a: ^^^!text^^^!" rem "a: ^!text^!" set "b=%a%" rem set "b=^^^!text^^^!" echo "b: %b%" rem echo "b: ^!tex...
by lockedscope
15 Jun 2020 05:05
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 5960

Re: Dynamic loop code over multiple lines causes extra quotes

I could simplify those carets into a variable so i have now 5 carets :) I still like to understand the caret escaping mechanism. :?: REM @echo off setlocal enableDelayedExpansion (set \n=^^^ %= This creates an escaped Line Feed - DO NOT ALTER =% ) (set text=11x y z%\n% 22d e f%\n% 33q w x) rem A sim...
by lockedscope
15 Jun 2020 03:20
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 5960

Re: Dynamic loop code over multiple lines causes extra quotes

I could finally escaped text variable to prevent from expansion without using extra variable. It worked with 10 or 11 carets, may be with more carets too. But i do not understand how it worked? I checked parsing rules but could not find any direct clue about this. Not sure about caret doubling phase...
by lockedscope
14 Jun 2020 13:40
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 5960

Re: Dynamic loop code over multiple lines causes extra quotes

Thanks T3RRY :wink: :wink: for all those efforts. So, i could get it without those quotes at the end. It might be because of correct escaping of quotes of param or escaping of text, i am not sure. But i wonder, how could i get rid of multiple variables for text? Are there any guide for multiple leve...
by lockedscope
13 Jun 2020 06:05
Forum: DOS Batch Forum
Topic: How delayed expansion works?
Replies: 3
Views: 4009

How delayed expansion works?

According the parsing rules (https://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/4095133) is following explanation correct? set "a=xyz" echo "a: !a!" set "b=^!a^!" echo "b: !b!" rem Output: "b: !a!" - Only Delayed expansion echo "b percent: %b%"...
by lockedscope
12 Jun 2020 13:13
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 5960

Dynamic loop code over multiple lines causes extra quotes

In following experimental code, i try to create dynamic code to loop over multiple lines. But an extra double quotes("") appear after the last echo. I solved it with a "rem", but not sure what causes it. So, what causes those quotes? Also, how to write this code elegantly, with less delayed expansio...