Euphoria
Ticket #897:
Wrong stripping of quotes in the command line
-
Reported by
Insolor
May 31, 2014
Testing program:
sequence cmd = command_line()
if length(cmd)>2 then
printf(1,"%s\n",{cmd[$]})
else
puts(1,"none\n")
end if
Command line:
eui test.exw "asdf qwer\"
Given output:
asdf qwer"
Expected output:
asdf qwer\
Traditionally, bugreport.ex output:
Version
----------------------------
4.1.0 development (5783:d41527402a7a, 2014-01-16 02:53:44)
Operating System
----------------------------
Platform: WinNT, Build: WinXP, :2
(Actually, my OS is Windows 8.1)
Details
1. Comment by Insolor
May 31, 2014
My current workaround:
if length(cmd)>2 then
path = cmd[3]
end if
if path[$]='\"' then
path=trim(path,'\"')
end if
if path[$]!='\\' then
path&='\\'
end if
2. Comment by Insolor
May 31, 2014
Of course, don't forget to check the length of path before subsequent operations
path = ""
if length(cmd)>2 then
path = cmd[3]
end if
if length(path)>0 then
if path[$]='\"' then
path=trim(path,'\"')
end if
if path[$]!='\\' then
path&='\\'
end if
end if
3. Comment by mattlewis
Jun 01, 2014
I think you're getting the correct thing. The backslash is telling your shell that the next quote is not a real quote, just like if it was inside a euphoria string. You need to use a correct command line invocation like:
> eui test.exw "asdf qwer\\"
4. Comment by DerekParnell
Jun 01, 2014
No so sure, Matt. Maybe on a Unix platform that is right, but on Windows the command line parsing is left to the application and not the shell. I suspect that we are doing this incorrectly on Windows. More research is required before we close this ticket.
5. Comment by Insolor
Jun 04, 2014
Ok, I tested this
eui test.exw "asdf qwer\\"
The result is:
asdf qwer\"
Tested on Win7
Euphoria Interpreter v4.0.5
Windows, Using Managed Memory
Revision Date: 2012-10-11, Id: 362497032f33
6. Comment by mattlewis
Jun 05, 2014
You're correct, Derek. I guess we need to either change something or document how we parse command lines.
7. Comment by jimcbrown
Jun 07, 2014
Has anyone asked gbonvehi about this?
http://scm.openeuphoria.org/hg/euphoria/rev/b257a1c07f20
http://openeuphoria.org/ticket/886.wc