[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] addition: sh-quote.c

From: Bruno Haible
Subject: Re: [Bug-gnulib] addition: sh-quote.c
Date: Tue, 3 Feb 2004 21:12:29 +0100
User-agent: KMail/1.5

Paul Eggert wrote:
> quotearg already does this, no?

Interesting, I always thought of quotearg as a tool for error messages...

The fit is indeed very close. Only four things prevent me from using quotearg
with shell_quoting_style:

1) '{', '}', '=' are not recognized as characters that force a quote.
   But in my second use case, the entire argv[] is passed through the quoting
   function. Since '{' and '}' at the beginning of the first word, and
   '=' in the first word of a shell command have special meaning, I'd need
   to call a different function for argv[0]. Or you add a new style
   shell_command_quoting_style that is like shell_quoting_style except
   that it also cares about '{', '}', '='.

2) The empty string is not transformed into ''.

3) A convenience function

    char * quotearg_alloc (char const *arg, size_t argsize,
                           struct quoting_options const *o);

   that produces an xmalloc()ed result would be useful. I understand I can
   do it myself through 2 invocations of quotearg_buffer, but it would be
   very handy nevertheless.

   I don't want to use quotearg_n etc. because it uses static storage.

4) [Quite theoretical, but anyway.] The handling of, say, BIG5 characters
   that end in 0x5C is according to POSIX. But some bash versions don't do it
   according to POSIX and "see" a backslash where none is meant to be.
   For safety, I'd better turn shell_always_quoting_style mode on if
   a multibyte character is seen which contains a byte whose ASCII value
   is >= 0x30 and not shell-safe, like '[' or '\\'.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]