#155264 - 2006-01-13 07:09 PM
bug (?) when passing variable on the commandline
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
Consider the following:
Code:
test.KiX contains just a single line of code ? $var
A few 'tests' give the following results:
D:\>KIX32.EXE test.KiX $var="abc" abc
D:\>KIX32.EXE test.KiX $var="a b c" a b c
D:\>KIX32.EXE test.KiX $var="\abc" \abc
D:\>KIX32.EXE test.KiX $var="\\abc" \\abc
D:\>KIX32.EXE test.KiX $var="a\b\c" a\b\c
D:\>KIX32.EXE test.KiX $var="abc\" abc"
D:\>KIX32.EXE test.KiX $var="abc\\" abc\
D:\>KIX32.EXE test.KiX $var="abc\\\" abc\"
D:\>KIX32.EXE test.KiX $var="abc\\\\" abc\\
D:\>KIX32.EXE test.KiX $var="\abc\\\\" \abc\\
D:\>KIX32.EXE test.KiX $var="\\abc\\\\" \\abc\\
D:\>KIX32.EXE test.KiX $var="\\\a\b\c\\\\" \\\a\b\c\\
Apperently an odd number of trailing backslashes produces incorrect results.
Btw.. tested with v4.50 on WinXP/SP2 and W2k3/SP1
|
Top
|
|
|
|
#155266 - 2006-01-13 07:26 PM
Re: *not a bug*
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
Read more carefully... First it only does it with training backslashes, not for backslashes in front or in the middle as my examples clearly show. Secondly why do I also get a double quote?
|
Top
|
|
|
|
#155268 - 2006-01-13 07:52 PM
Re: *not a bug*
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
Hmm.. interesting, then why have I been using a carot for years as the escape character in DOS? Try echo \> and echo ^> Again, escape character or not, the behaviour is not consistent and therefor a bug. I'd like Ruud's thoughts on this one.
|
Top
|
|
|
|
#155274 - 2006-01-13 09:08 PM
Re: *not a bug*
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
The issue is not just leading backslashes, also backslashes in the middle are not escaped. Or the other way around, only a trailing backslash is escaped.
Another example
Code:
D:\>KIX32.EXE test.KiX $var="\\aa\\bb\\cc\\" \\aa\\bb\\cc\ <- only the trailing backslash is escaped, I would have expected either \\aa\\bb\\cc\\ or \aa\bb\cc\ as result
D:\>KIX32.EXE test.KiX $var="\aa\bb\cc\" \aa\bb\cc" <- only the trailing backslash is escaped
|
Top
|
|
|
|
#155276 - 2006-01-13 10:50 PM
Re: *not a bug*
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
Ok, tried it out, the odd behaviour is apparently a "feature" of the C++ compiler of VS2003. Very curious how this is processed with a Watson compiler or on a linux box. I haven't done C or C++ since the early 90's so I've no easy test environment myself. Personally I consider this a bug of kixtart, oddities of a compiler should not be imposed on the user, sort of like your tagline Jooel But on former occasions I've learned that the board has some strict view about what is a kixtart or exterior problem so I guess I'll have to live with it.
Edit: found the ancient Borland C v3.1 on my system... not to my surprise it produces the imho correct expected results, that is the trailing backslash in NOT escaped. <--- not true.. see edit2 below
Edit2: I stand corrected, forgot to doublequote the arguments, BC3 behaves the same, guess it's a printf oddity then. Also tried VB6, vbscript and a DOS batch file, they do all produce the 'correct' result.
Edited by iffy (2006-01-13 10:59 PM)
|
Top
|
|
|
|
#155282 - 2006-01-14 10:16 AM
Re: *not a bug*
|
iffy
Starting to like KiXtart
Registered: 2005-05-29
Posts: 149
Loc: The Netherlands
|
My only point is that it is unexpected behaviour and I had to add extra code in my KiX script to fix the input.
Off topic rant & rave: As a user I don't really care if C/C++ has imho weird behaviour, I want simple consistent results. As I said before, why impose this on the end user of a product, in this case me. Why do I need to know and keep in mind in what language my compiler/interpreter was written? As a developer it was interesting to dig into it a little tho, understanding the 'deeper' cause makes for better code in the end... But all in all, I still wouldn't mind if the input was fixed and that KiX would produce the 'expected' results.
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 515 anonymous users online.
|
|
|