- May
- 382
- 2
I'm back from another thread with a modified script. SETDOS /X-4 behaves differently between v10 and v13 wrt aliases. In simple parsing cases the two versions behave the same, but when the alias is more complicated they behave differently, and I'm partial to the way v10 works, which seems correct to me.
Run in v10 TCC/LE:
Don't worry that it can't find the file, there's none to find in this case. Just note that the _action alias expands to COPY /n src "\tgt" "". Version 13 won't perform that expansion. Let's see. Run in v13 TCC:
Now comment out SETDOS /X-4 and run the script again in v13
The help file for version 13 doesn't say that SETDOS /X-4 disables variable expansion in aliases, but it does while it didn't in version 10.
Version 13 WAD or bug?
Regardless, I'd prefer to adapt my alias so it worked in v13 as in v10, with SETDOS /X-4 enabled. How could I rewrite my alias, any suggestions?
In fact, my script uses SETDOS /X-4 to allow for % in file pathnames. (yes! it's for a real use case). I've used Safecopy.dll before and would consider using it in this script, too. But how to use safecopy to deal with variables %[src] and %[tgt], which need expansion in the _action alias?
HTML:
@echo off
setlocal
setdos /X-4
alias _action=`%@if["/echo"=="%1",echo ]%[cp] %2 %@if[defined fDbg,/N] "%[src]%@if[%@len[%@ascii[%3]] GT 0,\%@unquotes[%3$]]" "%[tgt]"`
alias _action
set cp=copy /n
_action /echo src tgt
_action /do src tgt
unalias _action
endlocal
Run in v10 TCC/LE:
HTML:
E:\>tccle10\tcc.exe /LA /I c:\temp\qwqw.btm
TCC LE 10.00.74 Windows XP [Version 5.1.2600]
%@if["/echo"=="%1",echo ]%[cp] %2 %@if[defined fDbg,/N] "%[src]%@if[%@len[%@ascii[%3]] GT 0,\%@unquotes[%3$]]" "%[tgt]"
copy /n src "\tgt" ""
TCC: (Sys) C:\temp\qwqw.btm [8] The system cannot find the file specified.
""
0 files would be copied
E:\...\tipi>
HTML:
E:\>tcmd13\tcc.exe /LA /I c:\temp\qwqw.btm
TCC 13.00.21 Windows XP [Version 5.1.2600]
%@if["/echo"=="%1",echo ]%[cp] %2 %@if[defined fDbg,/N] "%[src]%@if[%@len[%@ascii[%3]] GT 0,\%@unquotes[%3$]]" "%[tgt]"
%[cp] src %@if[defined fDbg,/N] "%[src]\tgt" ""
TCC: C:\temp\qwqw.btm [8] Unknown command "%[cp]"
E:\>
HTML:
E:\>tcmd13\tcc.exe /LA /I c:\temp\qwqw.btm
TCC 13.00.21 Windows XP [Version 5.1.2600]
%@if["/echo"=="%1",echo ]%[cp] %2 %@if[defined fDbg,/N] "%[src]%@if[%@len[%@ascii[%3]] GT 0,\%@unquotes[%3$]]" "%[tgt]"
copy /n src "\tgt" ""
TCC: (Sys) C:\temp\qwqw.btm [8] The system cannot find the file specified.
""
0 files would be copied
E:\>
Version 13 WAD or bug?
Regardless, I'd prefer to adapt my alias so it worked in v13 as in v10, with SETDOS /X-4 enabled. How could I rewrite my alias, any suggestions?
In fact, my script uses SETDOS /X-4 to allow for % in file pathnames. (yes! it's for a real use case). I've used Safecopy.dll before and would consider using it in this script, too. But how to use safecopy to deal with variables %[src] and %[tgt], which need expansion in the _action alias?