Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Problem with peculiar CMD syntax

May
603
0
TCC 9.02.152 Windows XP [Version 5.1.2600]
TCC Build 152 Windows XP Build 2600 Service Pack 3

I have two questions:

1) Should environment variable substitution work, with the leading *?

This batch file shows two very different results in 4NT and CMD:
SET FOO=ABCDEFGHI
ECHO %FOO:*DEF=%

4NT:
"environment.htm" last edited 5/8/2008 says:
For compatibility with some peculiar syntax introduced in recent
CMD.EXE versions, TCC supports:
%var:string1=string2% -- Substitutes the second string for all
instances of the first string in the variable.

In CMD, SET /? shows:
%PATH:str1=str2% ... "str1" can begin with an asterisk, in which case
it will match everything from the beginning of the expanded output to
the first occurrence of the remaining portion of str1.


2) What I actually want to solve:

Our development tree for one project is always in some folder, with these extras

(some drive and folder)\KESTREL\X86
(some drive and folder)\KESTREL\COMMON
(some drive and folder)\KESTREL\MICROASM
etc.

We have a standard MAKE batch file that takes one subfolder as an
argument, e.g. MAKE X86, to build that subfolder. I was hoping to
allow it to translate, say a dot "." into "the current folder" so I
could CD to X86 and say "MAKE ." which would then figure out the
current folder and behave as if I had typed "MAKE X86"

I tried using %CD:*KESTREL\=% syntax which works great in CMD but not 4NT. Sigh.

Is there a single compatible line that will work in both?
Unfortunately, we are required to have it work in both shells.

--
2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Saturday.
Measure wealth by the things you have for which you would not take money.
 
You could try this:

if %@EVAL[1+1] == 2 (
set Proj=%@name[%_CWD]
) else (
set Proj=%CD:*KESTREL\=%
)

-Scott

"JP Software Forums" <[email protected]> wrote on 10/02/2008 04:20:50 PM:


> TCC 9.02.152 Windows XP [Version 5.1.2600]
> TCC Build 152 Windows XP Build 2600 Service Pack 3
>
> I have two questions:
>
> 1) Should environment variable substitution work, with the leading *?
>
> This batch file shows two very different results in 4NT and CMD:
> SET FOO=ABCDEFGHI
> ECHO %FOO:*DEF=%
>
> 4NT:
> "environment.htm" last edited 5/8/2008 says:
> For compatibility with some peculiar syntax introduced in recent
> CMD.EXE versions, TCC supports:
> %var:string1=string2% -- Substitutes the second string for all
> instances of the first string in the variable.
>
> In CMD, SET /? shows:
> %PATH:str1=str2% ... "str1" can begin with an asterisk, in which case
> it will match everything from the beginning of the expanded output to
> the first occurrence of the remaining portion of str1.
>
>
> 2) What I actually want to solve:
>
> Our development tree for one project is always in some folder, with
> these extras
>
> (some drive and folder)\KESTREL\X86
> (some drive and folder)\KESTREL\COMMON
> (some drive and folder)\KESTREL\MICROASM
> etc.
>
> We have a standard MAKE batch file that takes one subfolder as an
> argument, e.g. MAKE X86, to build that subfolder. I was hoping to
> allow it to translate, say a dot "." into "the current folder" so I
> could CD to X86 and say "MAKE ." which would then figure out the
> current folder and behave as if I had typed "MAKE X86"
>
> I tried using %CD:*KESTREL\=% syntax which works great in CMD but
> not 4NT. Sigh.
>
> Is there a single compatible line that will work in both?
> Unfortunately, we are required to have it work in both shells.
>
> --
> 2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
> Next year they're Saturday.
> Measure wealth by the things you have for which you would not take
money.
 
> if %@EVAL[1+1] == 2 (
> set Proj=%@name[%_CWD]
> ) else (
> set Proj=%CD:*KESTREL\=%
> )
> -Scott

I'm currently testing %_4VER for empty in two lines of code -- much
the same. I was hoping for just one syntax that was the same in each,
instead of selecting the different syntaxes.

I was using %@WORD, and like your suggestion of @NAME much better.
Don't know why I didn't think of that.


--
2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Saturday.
Measure wealth by the things you have for which you would not take money.
 

Similar threads

Back
Top