1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
4 Copyright (C) 2001-2004, 2006, 2009-2011 Free Software Foundation, Inc.
5 Written by Bruno Haible <haible@clisp.cons.org>, 2001.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
30 /* Describes quoting for sh compatible shells. */
31 static struct quoting_options *sh_quoting_options;
33 /* Initializes the sh_quoting_options variable. */
35 init_sh_quoting_options (void)
37 sh_quoting_options = clone_quoting_options (NULL);
38 set_quoting_style (sh_quoting_options, shell_quoting_style);
41 /* Returns the number of bytes needed for the quoted string. */
43 shell_quote_length (const char *string)
45 if (sh_quoting_options == NULL)
46 init_sh_quoting_options ();
47 return quotearg_buffer (NULL, 0, string, strlen (string),
51 /* Copies the quoted string to p and returns the incremented p.
52 There must be room for shell_quote_length (string) + 1 bytes at p. */
54 shell_quote_copy (char *p, const char *string)
56 if (sh_quoting_options == NULL)
57 init_sh_quoting_options ();
58 return p + quotearg_buffer (p, (size_t)(-1), string, strlen (string),
62 /* Returns the freshly allocated quoted string. */
64 shell_quote (const char *string)
66 if (sh_quoting_options == NULL)
67 init_sh_quoting_options ();
68 return quotearg_alloc (string, strlen (string), sh_quoting_options);
71 /* Returns a freshly allocated string containing all argument strings, quoted,
72 separated through spaces. */
74 shell_quote_argv (char **argv)
86 length += shell_quote_length (*argp) + 1;
92 command = XNMALLOC (length, char);
97 p = shell_quote_copy (p, *argp);