Function

GLibshell_parse_argv

Declaration [src]

gboolean
g_shell_parse_argv (
  const gchar* command_line,
  gint* argcp,
  gchar*** argvp,
  GError** error
)

Description [src]

Parses a command line into an argument vector, in much the same way the shell would, but without many of the expansions the shell would perform (variable expansion, globs, operators, filename expansion, etc. are not supported).

The results are defined to be the same as those you would get from a UNIX98 /bin/sh, as long as the input contains none of the unsupported shell expansions. If the input does contain such expansions, they are passed through literally.

Possible errors are those from the G_SHELL_ERROR domain.

Free the returned vector with g_strfreev().

Parameters

command_line const gchar*
 

Command line to parse.

 The data is owned by the caller of the function.
 The string is a file system path, using the OS encoding.
argcp gint*
 

Return location for number of args.

 The argument will be set by the function.
 The argument can be NULL.
 The called function takes ownership of the data, and is responsible for freeing it.
argvp An array of filename
 

return location for array of args.

 The argument will be set by the function.
 The argument can be NULL.
 The array must be NULL-terminated.
 The length of the array is specified in the argcp argument.
 The called function takes ownership of the data, and is responsible for freeing it.
error GError **
  The return location for a GError*, or NULL.

Return value

Returns: gboolean
 

TRUE on success, FALSE if error set.