[gnome-shell] extensions-tool: Handle NULL input when prompting for metadata
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensions-tool: Handle NULL input when prompting for metadata
- Date: Tue, 7 Apr 2020 20:33:16 +0000 (UTC)
commit b6262f06669a6b2e27b302b32765a83acba55c1b
Author: Florian Müllner <fmuellner gnome org>
Date: Tue Apr 7 01:49:30 2020 +0200
extensions-tool: Handle NULL input when prompting for metadata
g_data_input_stream_read_line_utf8() may return NULL, for example
when interrupting the prompt with ^D. Handle that case and keep
prompting until we got a line.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/812
subprojects/extensions-tool/src/command-create.c | 30 +++++++++++++++++-------
1 file changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/subprojects/extensions-tool/src/command-create.c
b/subprojects/extensions-tool/src/command-create.c
index 7fb5d7a78f..2ee1369f6b 100644
--- a/subprojects/extensions-tool/src/command-create.c
+++ b/subprojects/extensions-tool/src/command-create.c
@@ -188,42 +188,54 @@ prompt_metadata (char **uuid, char **name, char **description)
if (name != NULL && *name == NULL)
{
- char *line;
+ char *line = NULL;
g_print (
_("Name should be a very short (ideally descriptive) string.\n"
"Examples are: %s"),
"“Click To Focus”, “Adblock”, “Shell Window Shrinker”\n");
- g_print ("%s: ", _("Name"));
- line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ while (line == NULL)
+ {
+ g_print ("%s: ", _("Name"));
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ }
*name = g_strdelimit (line, "\n", '\0');
}
if (description != NULL && *description == NULL)
{
- char *line;
+ char *line = NULL;
g_print (
_("Description is a single-sentence explanation of what your extension does.\n"
"Examples are: %s"),
"“Make windows visible on click”, “Block advertisement popups”, “Animate windows shrinking on
minimize”\n");
- g_print ("%s: ", _("Description"));
- line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ while (line == NULL)
+ {
+ g_print ("%s: ", _("Description"));
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ }
*description = g_strdelimit (line, "\n", '\0');
}
if (uuid != NULL && *uuid == NULL)
{
- char *line;
+ char *line = NULL;
g_print (
_("UUID is a globally-unique identifier for your extension.\n"
"This should be in the format of an email address (clicktofocus janedoe example com)\n"));
- g_print ("UUID: ");
- line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ while (line == NULL)
+ {
+ g_print ("UUID: ");
+
+ line = g_data_input_stream_read_line_utf8 (istream, NULL, NULL, NULL);
+ }
*uuid = g_strdelimit (line, "\n", '\0');
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]