[wpkg-users] find/findstr and multibyte...
Dave Evans
dave.evans at goodness.co.uk
Tue May 24 23:31:41 CEST 2016
On 24/05/2016 16:31, Marco Gaiarin wrote:
>> https://windowsnlmtool.codeplex.com/
> I reply to myself. I've done some test with 'findstring' and found that
> some match are possible:
>
> C:\Users\Administrator>\\file\wpkg\tools\NLMtool64.exe | findstr /r /c:"C.a.t.e.g.o.r.y.:. .P.R.I.V.A.T.E."
> C a t e g o r y : P R I V A T E
> C:\Users\Administrator>echo %ERRORLEVEL%
> 0
>
> So i've setup that check condition on a recipe:
>
> <check type="logical" condition="or">
> <check type="logical" condition="and">
> <check type="host" condition="architecture" value="x86" />
> <check type="execute" path='%COMSPEC% /c "%WPKGROOT%\tools\NLMTool.exe" | findstr /r /c:"C.a.t.e.g.o.r.y.:. .P.R.I.V.A.T.E."' condition="exitcodeequalto" value="0" />
> </check>
> <check type="logical" condition="and">
> <check type="host" condition="architecture" value="x64" />
> <check type="execute" path='%COMSPEC% /c "%WPKGROOT%\tools\NLMTool64.exe" | findstr /r /c:"C.a.t.e.g.o.r.y.:. .P.R.I.V.A.T.E."' condition="exitcodeequalto" value="0" />
> </check>
> </check>
>
> if i use '%COMSPEC% /c', match is ever FALSE; if i omit it, match is
> ever TRUE.
>
> Why? Thanks.
Obviously I don't know which way you're trying to make that work, but
the whole code can be simplified like this:
<variable name="arch" value=""/>
<variable name="arch" value="64" architecture="x64"/>
<check type="execute" path='%COMSPEC% /c
"%WPKGROOT%\tools\NLMTool%arch%.exe" | findstr /r /c:"C.a.t.e.g.o.r.y.:.
.P.R.I.V.A.T.E."' condition="exitcodeequalto" value="0" />
note that findstr (like find) returns a non-zero error code if the
string is NOT found, so your check should come out TRUE if the string is
found
as to the question you posed why is it different if you use %comspec% /c?
have you tried doing
%COMSPEC% /c "%WPKGROOT%\tools\NLMTool%arch%.exe" > file1.txt
"%WPKGROOT%\tools\NLMTool%arch%.exe" > file2.txt
then open the two files with a text editor (or a hex editor) and see if
there are any differences.
Dave
More information about the wpkg-users
mailing list