* quoted environment arguments
@ 2010-10-18 13:48 Philipp Gesang
0 siblings, 0 replies; only message in thread
From: Philipp Gesang @ 2010-10-18 13:48 UTC (permalink / raw)
To: ntg-context
[-- Attachment #1.1.1: Type: text/plain, Size: 1626 bytes --]
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
[-- Attachment #1.1.2: luat-env.patch --]
[-- Type: text/plain, Size: 681 bytes --]
--- /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 #1.2: Type: application/pgp-signature, Size: 198 bytes --]
[-- Attachment #2: Type: text/plain, Size: 486 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-10-18 13:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-18 13:48 quoted environment arguments Philipp Gesang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).