All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Philip Oakley" <philipoakley@iee.org>
Cc: "GitList" <git@vger.kernel.org>,
	 "Marius Storm-Olsen" <mstormo@gmail.com>,
	 "Ramsay Jones" <ramsay@ramsay1.demon.co.uk>,
	 "Jonathan Nieder" <jrnieder@gmail.com>,
	 "Michael Wookey" <michaelwookey@gmail.com>,
	 "Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	 "Msysgit" <msysgit@googlegroups.com>
Subject: Re: [RFC 2/4] Properly accept quoted space in filenames
Date: Fri, 21 Nov 2014 15:21:44 -0800	[thread overview]
Message-ID: <xmqqa93kywaf.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <9E7656E05CE648B3A357858B4520110D@PhilipOakley> (Philip Oakley's message of "Fri, 21 Nov 2014 23:11:08 -0000")

"Philip Oakley" <philipoakley@iee.org> writes:

> From: "Junio C Hamano" <gitster@pobox.com>
>> Philip Oakley <philipoakley@iee.org> writes:
>>
>>>  sub handleCompileLine
>>>  {
>>>      my ($line, $lineno) = @_;
>>> -    my @parts = split(' ', $line);
>>> +    # my @parts = split(' ', $line);
>>> +    my @parts = quotewords('\s+', 0, $line);
>>
>> Can somebody enlighten me why/if quotewords is preferrable over
>> shellwords in the context of this patch?
>
> "No" - Ignorance is bliss ;-) I think my cargo culting was the result
> of some googling for "quoting perl variables" or some such, which
> obviously came up with quotewords - I'm happy to take advice on this
> one!
>
> quotewords did appear to work though back when I wrote this: 86dcfcf
> (Properly accept quoted space in filenames, 2012-05-06)

A quick websearch shows me:

  http://cpansearch.perl.org/src/CHORNY/Text-ParseWords-3.29/ParseWords.pm

and comparing the implementations of the two, the difference boils
down to just one line to me.

    sub shellwords {
        my (@lines) = @_;
        my @allwords;

        foreach my $line (@lines) {
            $line =~ s/^\s+//;
            my @words = parse_line('\s+', 0, $line);
            pop @words if (@words and !defined $words[-1]);
            return() unless (@words || !length($line));
            push(@allwords, @words);
        }
        return(@allwords);
    }

In quotewords, the call to parse_line uses $keep not hardcoded 0
(which would not make any difference in the context of your patch),
and it assumes parse_line() never returns a singleton "undef" so the
line "pop ... if @words is a list with 'undef' as its sole element"
is missing.

Of course, the caller would become smaller and sweeter, i.e.

    my @parts = shellwords($line);

I am not familiar with if Perl folks have certain convention to
decide when to use which one, though ;-)




-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  reply	other threads:[~2014-11-21 23:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 23:37 [RFC 0/4] Fix the Visual Studio 2008 .sln generator Philip Oakley
2014-11-20 23:37 ` [RFC 1/4] Fix i18n -o option in msvc engine.pl Philip Oakley
2014-11-21  9:41   ` Johannes Schindelin
2014-11-21 20:27     ` Philip Oakley
2014-11-20 23:38 ` [RFC 2/4] Properly accept quoted space in filenames Philip Oakley
2014-11-21  9:42   ` Johannes Schindelin
2014-11-21 22:34   ` Junio C Hamano
2014-11-21 23:11     ` Philip Oakley
2014-11-21 23:21       ` Junio C Hamano [this message]
2014-11-20 23:38 ` [RFC 3/4] engine.pl: split the .o and .obj processing Philip Oakley
2014-11-21  9:48   ` Johannes Schindelin
2014-11-21 20:35     ` Philip Oakley
2014-11-23 15:28       ` Johannes Schindelin
2014-11-23 22:50         ` Philip Oakley
2014-11-20 23:38 ` [RFC 4/4] Improve layout and reference msvc-build script Philip Oakley
2014-11-21  9:51   ` Johannes Schindelin
2014-11-21 21:05     ` Philip Oakley
2014-11-21  9:38 ` [RFC 0/4] Fix the Visual Studio 2008 .sln generator Johannes Schindelin
2014-11-21 20:22   ` Philip Oakley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa93kywaf.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=michaelwookey@gmail.com \
    --cc=mstormo@gmail.com \
    --cc=msysgit@googlegroups.com \
    --cc=philipoakley@iee.org \
    --cc=ramsay@ramsay1.demon.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.