[PATCH 1 of 2 STABLE V2] util: add "shellsplit()" to centralize the logic to split command line

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Dec 5 05:22:50 CST 2014


At Fri, 05 Dec 2014 02:22:32 +0900,
FUJIWARA Katsunori wrote:
> 
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1417712035 -32400
> #      Fri Dec 05 01:53:55 2014 +0900
> # Branch stable
> # Node ID 427cb697d124bea1a7e67ebcdeca2fea81a925c0
> # Parent  57d35d3c1cf170513cc150c5021f5e3e0d7cdafb
> util: add "shellsplit()" to centralize the logic to split command line
> 
> This is the preparation for fixing issue4463.
> 
> This patch uses StringIO object to know exactly where the first shell
> delimiter character is placed, because "shlex.next()" returns the
> de-quoted string and this makes eliminating it from original string
> difficult in some complicated cases.
> 
> For example, "shlex.next()" for '"foo"/"foo" bar baz' returns 'foo/foo'.
> 
> On the other hand, "StringIO.tell()" allows us to know exactly what
> characters are not yet read in by shlex.
> 
> Another patch series for "default" branch will replace existing
> "shlex.split()" invocations by "util.shellsplit()" (and add new
> "check-code.py" rule to prevent from using "shlex.split()").

Please ignore this series, if this is not yet reviewed/queued.

I found that patch #1 of this series can become more suitable to be
checked about "use util.shellsplit instead of shlex.split" by
"check-code.py".

I'll post revised series soon.

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list