git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug: git-p4 edit_template() and P4EDITOR w/options

From
CLChris Lasell <chrisl@pixar.com>
Date
May 4, 2015, 22:46 UTC
Message-ID
<8AC0C799-2402-4AAB-8C9D-271FBF14910D@pixar.com>
In-Reply-To
<xmqqzj5knf2t.fsf@gitster.dls.corp.google.com>
Show 18 quoted lines
> On May 4, 2015, at 3:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Junio C Hamano <gitster@pobox.com> writes:
> 
> So, use_shell==true codepath grabs that array with "editor", "path"
> and turns it into an equivalent to
> 
> 	sh -c "$EDITOR" "$path"
> 
> when $EDITOR has a "magic" character (including whitespace) in it.
> So what git-p4 does is *not* in line with how we use the environment
> variable.
> 
> Perhaps a single-liner patch like this would work?
> 
> -	system([editor, template_file])
> +	system(["sh", "-c", editor, template_file])
> 
Thanks for the input Junio!
I’ll try it out, but leave the decision about patching  for the maintainers :-)
Though I do notice that their "system()" function does do shell expansion if it’s arg is a string, but not if it’s a list:
def system(cmd):
    expand = isinstance(cmd,basestring)
    if verbose:
        sys.stderr.write("executing %s\n" % str(cmd))
    retcode = subprocess.call(cmd, shell=expand)
    if retcode:
        raise CalledProcessError(retcode, cmd)
and the edit_template() function is passing a list
I had thought about writing a tiny wrapper script as mentioned in that first link you sent, but that felt even more out of line, especially since there are many references on the net to using parameters in EDITOR vars, particularly with mate.
FWIW, my user is all set now, but I’m happy to participate in this conversation if appropriate :-)

Cheers, -Chris

Previous: Junio C Hamano
Message 8 of 8 in “Bug: git-p4 edit_template() and P4EDITOR w/options”
  1. Chris LasellMay 4, 2015
  2. Junio C HamanoMay 4, 2015
  3. Junio C HamanoMay 4, 2015
  4. Junio C HamanoMay 4, 2015
  5. Junio C HamanoMay 4, 2015
  6. Jonathan NiederMay 4, 2015
  7. Junio C HamanoMay 5, 2015
  8. Chris LasellMay 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.