mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-21 16:38:54 +02:00
shell: Handle empty comment gracefully
Parsing scripts using g_shell_parse_argv() line by line, it's useful to have empty comments, so one can write pragraphs etc, e.g. # This is a comment with multiple paragraphs. # # It's useful to split things up like this at times. # # The empty comment characters makes it clear the paragraphs form a # single comment.
This commit is contained in:
@@ -580,6 +580,11 @@ tokenize_command_line (const gchar *command_line,
|
||||
_("Text ended just after a “\\” character."
|
||||
" (The text was “%s”)"),
|
||||
command_line);
|
||||
else if (current_quote == '#')
|
||||
g_set_error (error,
|
||||
G_SHELL_ERROR,
|
||||
G_SHELL_ERROR_EMPTY_STRING,
|
||||
_("Text was empty (or contained only whitespace)"));
|
||||
else
|
||||
g_set_error (error,
|
||||
G_SHELL_ERROR,
|
||||
|
@@ -67,6 +67,7 @@ static CmdlineTest cmdline_tests[] =
|
||||
{ "", 0, { NULL }, G_SHELL_ERROR_EMPTY_STRING },
|
||||
{ " ", 0, { NULL }, G_SHELL_ERROR_EMPTY_STRING },
|
||||
{ "# foo bar", 0, { NULL }, G_SHELL_ERROR_EMPTY_STRING },
|
||||
{ "#", 0, { NULL }, G_SHELL_ERROR_EMPTY_STRING },
|
||||
{"foo '/bar/summer'\\''09 tours.pdf'", 2, {"foo", "/bar/summer'09 tours.pdf", NULL}, -1}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user