Page 1 of 3 123>
Topic Options
#155264 - 2006-01-13 07:09 PM bug (?) when passing variable on the commandline
iffy Offline
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
#155265 - 2006-01-13 07:22 PM *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
instead of commandline, use startmenu run.

see the difference?

this is normal dos thing.
backslash is a escape character and thus the results are obvious, right?
_________________________
!

download KiXnet

Top
#155266 - 2006-01-13 07:26 PM Re: *not a bug*
iffy Offline
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
#155267 - 2006-01-13 07:44 PM Re: *not a bug*
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
On the commandline, the hack \ has special meaning. It is the *escape* character.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#155268 - 2006-01-13 07:52 PM Re: *not a bug*
iffy Offline
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
#155269 - 2006-01-13 08:07 PM Re: *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
echo is proven to be non-standard among the commandline tools.
anyway using double backslashes donates that there should be a backslash.
using 1,3,5 or so on, escapes the next character.
that's ok behavior in my mind.

the issue I do see here is that the leading backslashes are not escaped.

another issue I do see that I can't reproduce your issue
just tried out and my Wkix32.exe 4.52 beta2 does not do this.
nor did 4.51
_________________________
!

download KiXnet

Top
#155270 - 2006-01-13 08:18 PM Re: bug (?) when passing variable on the commandline
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, after some testing I can confirm that the behavior of kix32.exe and wkix32.exe do differ.
_________________________
!

download KiXnet

Top
#155271 - 2006-01-13 08:30 PM Re: *not a bug*
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Quote:

Try echo \> and echo ^>



As Jooel said, ECHO is not the same as commandline. Shawn will attest to that as we recently discussed it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#155272 - 2006-01-13 08:44 PM Re: *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, I made a simple test app with c++

and by posthing this, I even made it "open source"
Code:

int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0;i<argc;i++) {
int o = printf("%d -> %s\n",i, argv[i]);
}
return 0;
}



you can get it from HERE

with this, it's proven that it's not a kixtart issue.
_________________________
!

download KiXnet

Top
#155273 - 2006-01-13 08:50 PM Re: *not a bug*
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Here is Shawn's topic:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=153766
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#155274 - 2006-01-13 09:08 PM Re: *not a bug*
iffy Offline
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
#155275 - 2006-01-13 09:40 PM Re: *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
iffy, try out that exe.
it outputs what you give it as arguments to the console.
and my exe has nothing to do with kixtart.
but is build with the normal exe headers but otherwise is just that main I posted.


Edited by Jooel (2006-01-13 10:37 PM)
_________________________
!

download KiXnet

Top
#155276 - 2006-01-13 10:50 PM Re: *not a bug*
iffy Offline
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
#155277 - 2006-01-13 11:00 PM Re: *not a bug*
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I just compiled and ran Jooel's code under Visual Studio 6 ... same results.
Top
#155278 - 2006-01-14 12:26 AM Re: *not a bug*
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
I confirmed Iffy results on a .bat and .vbs file returning the "expected" results. While this is may not be a bug in kixtart, I can certainly relate with Iffy that this would be unexpected behavior.
Top
#155279 - 2006-01-14 12:37 AM Re: *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
allen, how you can confirm this with bat?
ofcourse same question goes for anyone saying they can get "correct" result with bat.
remember, echo is not the answer here.

hmm...
set neither changes it.
and that's about it.
not sure how would more test it.
I shall try changing my exe a bit...


Edited by Jooel (2006-01-14 12:47 AM)
_________________________
!

download KiXnet

Top
#155280 - 2006-01-14 01:03 AM Re: *not a bug*
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4545
Loc: USA
I used echo and set as tests.
Top
#155281 - 2006-01-14 01:07 AM Re: *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
oh, and if someone thinks printf() has an issue, here is a highschool version of the test code:
Code:

#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 0;i<argc;i++) {
cout << i << " -> " << argv[i] << "\n";
}
return 0;
}



and the results are the same.
the last backslashes are escaped.

also, if I place some backslashes before the first quote (right before the arg that is), they also are escaped.

so, again, my VS has nothing to do with kix (except that kixtart was probably build with VS too) and still my programs have the same "issue"
that is, the issue is not kixtart related.
_________________________
!

download KiXnet

Top
#155282 - 2006-01-14 10:16 AM Re: *not a bug*
iffy Offline
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
#155283 - 2006-01-14 11:08 AM Re: *not a bug*
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
yes.
I hear you.
the point I was trying to make here is that fixing this behaviour isn't that easy.

anyway, until ruud comments on this, you can always use wkix32.exe as workaround.
_________________________
!

download KiXnet

Top
Page 1 of 3 123>


Moderator:  ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.121 seconds in which 0.068 seconds were spent on a total of 13 queries. Zlib compression enabled.