Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
quotearg.c's shell_quoting_style and MinGW
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 30 of 30 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Bruno Haible  
View profile  
 More options May 6 2012, 4:25 pm
Newsgroups: gnu.utils.bug
From: Bruno Haible <br...@clisp.org>
Date: Sun, 06 May 2012 22:25:12 +0200
Local: Sun, May 6 2012 4:25 pm
Subject: Re: quotearg.c's shell_quoting_style and MinGW

Eli Zaretskii wrote:
> use a different set of styles: a "shell command-line argument" quoting
> style and a "file-name" quoting style.  The former would be used for
> producing shell commands, and will use platform-dependent quoting,
> similar to the patch I sent.  The latter would be used for quoting
> file names which are not meant to be passed to a shell

Yes, this idea of thinking is good: Different purposes need different
ways of quoting.

But instead of putting it all into the 'quotearg' module - whose primary
purpose has historically been error messages and file names -, I would
assiociate the "file-name" quoting style with the 'quotearg' module and
the "command-line argument" style with the following new API, closely
modeled on sh-quote.h.

=============================== system-quote.h ===============================
/* Quoting for a system command.
   Copyright (C) 2001-2012 Free Software Foundation, Inc.
   Written by Bruno Haible <br...@clisp.org>, 2012.

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#ifndef _SYSTEM_QUOTE_H
#define _SYSTEM_QUOTE_H

/* When passing a command the system's command interpreter, we must quote the
   program name and arguments, since
     - Unix shells interpret characters like " ", "'", "<", ">", "$" etc. in a
       special way,
     - Windows CreateProcess() interprets characters like ' ', '\t', '\\', '"'
       etc. (but not '<' and '>') in a special way,
     - Windows cmd.exe also interprets characters like '<', '>', '&', '%', etc.
       in a special way.  */

#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Identifier for the kind of interpreter of the command.  */
enum system_command_interpreter
{
  /* The interpreter used by the system() and popen() functions.
     This is equivalent to SCI_POSIX_SH on Unix platforms and
     SCI_WINDOWS_CMD on native Windows platforms.  */
  SCI_SYSTEM
  /* The POSIX /bin/sh.  */
  , SCI_POSIX_SH
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
  /* The native Windows CreateProcess() function.  */
  , SCI_WINDOWS_CREATEPROCESS
  /* The native Windows cmd.exe interpreter.  */
  , SCI_WINDOWS_CMD
#endif

};

/* Returns the number of bytes needed for the quoted string.  */
extern size_t
       system_quote_length (enum system_command_interpreter interpreter,
                            const char *string);

/* Copies the quoted string to p and returns the incremented p.
   There must be room for shell_quote_length (string) + 1 bytes at p.  */
extern char *
       system_quote_copy (enum system_command_interpreter interpreter,
                          char *p, const char *string);

/* Returns the freshly allocated quoted string.  */
extern char *
       system_quote (enum system_command_interpreter interpreter,
                     const char *string);

/* Returns a freshly allocated string containing all argument strings, quoted,
   separated through spaces.  */
extern char *
       system_quote_argv (enum system_command_interpreter interpreter,
                          const char * const *argv);

#ifdef __cplusplus

}

#endif

#endif /* _SYSTEM_QUOTE_H */
=========================================================================== ===

The system_quote_argv function would be what I called create_system_command
earlier, with the added 'interpreter' argument.

For GNU diffutils, this means just replacing specific uses of
sh_quote with system_quote(SCI_SYSTEM, ...), right before the calls to
popen() and system().

How does that sound?

Bruno


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eli Zaretskii  
View profile  
 More options May 6 2012, 4:35 pm
Newsgroups: gnu.utils.bug
From: Eli Zaretskii <e...@gnu.org>
Date: Sun, 06 May 2012 23:35:58 +0300
Local: Sun, May 6 2012 4:35 pm
Subject: Re: quotearg.c's shell_quoting_style and MinGW

Sounds good to me, thanks.

So on Posix hosts, this new API will probably simply call the
shell-style quoting, while on non-Posix hosts it will use separate
code, is that right?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruno Haible  
View profile  
 More options May 6 2012, 4:59 pm
Newsgroups: gnu.utils.bug
From: Bruno Haible <br...@clisp.org>
Date: Sun, 06 May 2012 22:59:20 +0200
Local: Sun, May 6 2012 4:59 pm
Subject: Re: quotearg.c's shell_quoting_style and MinGW

Eli Zaretskii wrote:
> So on Posix hosts, this new API will probably simply call the
> shell-style quoting, while on non-Posix hosts it will use separate
> code, is that right?

Right.

Bruno


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Eggert  
View profile  
 More options May 6 2012, 5:12 pm
Newsgroups: gnu.utils.bug
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sun, 06 May 2012 14:12:23 -0700
Local: Sun, May 6 2012 5:12 pm
Subject: Re: quotearg.c's shell_quoting_style and MinGW
On 05/06/2012 12:34 PM, Bruno Haible wrote:

> Here are two more proposals, designed to avoid the drawbacks of the
> previous ones:

Thanks.  Either of those would work.  I prefer option 3
(popenv / systemv) as it offers more opportunity for
optimization on GNUish hosts, which can use vfork or the
equivalent to get better performance.  Such optimizations
aren't that important for diffutils but might matter
more in other applications.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bruno Haible  
View profile  
 More options May 6 2012, 6:13 pm
Newsgroups: gnu.utils.bug
From: Bruno Haible <br...@clisp.org>
Date: Mon, 07 May 2012 00:13:50 +0200
Local: Sun, May 6 2012 6:13 pm
Subject: Re: quotearg.c's shell_quoting_style and MinGW

Paul Eggert wrote:
> Thanks.  Either of those would work.

Good. I'll concentrate on option 4 in the next few days. This part is
needed for option 3 as well.

> I prefer option 3
> (popenv / systemv) as it offers more opportunity for
> optimization on GNUish hosts, which can use vfork or the
> equivalent to get better performance.  Such optimizations
> aren't that important for diffutils but might matter
> more in other applications.

OK. I think Eli's immediate needs will be fulfilled by option 4
(system-quote.h), but if you want to implement option 3 (popenv, systemv)
on top of that, feel free to.

For applications that want the optimized code - no use of /bin/sh and
use of vfork() if possible - we currently have the 'execute' and 'spawn-pipe'
modules; so the current situation is not that bad. (It would be even better
if we had a posix_spawn that works also on mingw. Has been on my TODO list
for ages...)

Bruno


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »