Hi,

there’s a behaviour concerning how context handles forced quotes
in command line arguments that I do not understand.

··· <example> ···················································

for i=-1,#environment.rawarguments do
    print(i, environment.rawarguments[i], environment.originalarguments[i])
end

·· </example> ···················································

Now run this as ‘test.lua’ with mtxrun:

  # mtxrun --script test.lua \"simple\" \"more complex\"

Here I get the following output:

··· <result> ····················································

-1  texlua  texlua
0   /home/kokytos/context/tex/texmf-linux/bin/mtxrun    
/home/kokytos/context/tex/texmf-linux/bin/mtxrun
1   --script    --script
2   test.lua    test.lua
3   "simple"    simple"
4   "more   more complex
5   complex"    nil

·· </result> ····················································

Number 3 indicates that a quoted argument is fully unquoted iff
it gets parsed into multiple arguments. It also leads to
‘Unbalanced quotes in argument ./simple"’ when used with the main
‘context’ script. It would make sense if you expect only args
containing spaces to be explicitly quoted, though.

I would propose a patch like the one I attached but I’m having
difficulties testing locally modified copies of the core Lua
files, so it remains untested.

Philipp
--- /home/kokytos/base/luat-env.lua     2010-10-18 15:23:24.053334794 +0200
+++ luat-env.lua        2010-10-18 15:27:47.320001408 +0200
@@ -183,10 +183,12 @@
     for index=1,#arg do
         local argument = arg[index]
         if find(argument,"^\"") then
-            newarg[#newarg+1] = gsub(argument,"^\"","")
             if not find(argument,"\"$") then
                 instring = true
+            else
+                argument = argument:gsub("\"$", "")
             end
+            newarg[#newarg+1] = gsub(argument,"^\"","")
         elseif find(argument,"\"$") then
             newarg[#newarg] = newarg[#newarg] .. " " .. gsub(argument,"\"$","")
             instring = false

Attachment: pgpYwsNgpxwGe.pgp
Description: PGP signature

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to