From 2ad7b03874a7dd196ff15e4a0834688b47ca373c Mon Sep 17 00:00:00 2001 From: Burt P Date: Thu, 13 Jul 2017 01:35:52 -0500 Subject: Fix Python detection, add Perl6, scan_dev() tweak * Python2 detection needs to look at stderr instead of stdout * Python3 detection looks at stdout * Perl6 detection * scan_dev() now captures stdout and stderr and ignores the one it doesn't want. This prevents messages from appearing in the console when the scan happens. Signed-off-by: Burt P --- modules/computer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'modules') diff --git a/modules/computer.c b/modules/computer.c index 97369db5..5789e95e 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -198,8 +198,12 @@ void scan_dev(gboolean reload) gboolean stdout; } detect_lang[] = { { N_("Scripting Languages"), NULL, FALSE }, - { N_("CPython"), "python -V", "\\d+\\.\\d+\\.\\d+", TRUE }, + { N_("Python"), "python -V", "\\d+\\.\\d+\\.\\d+", FALSE }, + { N_("Python2"), "python2 -V", "\\d+\\.\\d+\\.\\d+", FALSE }, + { N_("Python3"), "python3 -V", "\\d+\\.\\d+\\.\\d+", TRUE }, { N_("Perl"), "perl -v", "\\d+\\.\\d+\\.\\d+", TRUE }, + { N_("Perl6 (VM)"), "perl6 -v", "(?<=This is ).*", TRUE }, + { N_("Perl6"), "perl6 -v", "(?<=implementing Perl )\\w*\\.\\w*", TRUE }, { N_("PHP"), "php --version", "\\d+\\.\\d+\\.\\S+", TRUE}, { N_("Ruby"), "ruby --version", "\\d+\\.\\d+\\.\\d+", TRUE }, { N_("Bash"), "bash --version", "\\d+\\.\\d+\\.\\S+", TRUE}, @@ -229,7 +233,7 @@ void scan_dev(gboolean reload) for (i = 0; i < G_N_ELEMENTS(detect_lang); i++) { gchar *version = NULL; - gchar *output; + gchar *output, *ignored; gchar *temp; GRegex *regex; GMatchInfo *match_info; @@ -241,10 +245,11 @@ void scan_dev(gboolean reload) } if (detect_lang[i].stdout) { - found = g_spawn_command_line_sync(detect_lang[i].version_command, &output, NULL, NULL, NULL); + found = g_spawn_command_line_sync(detect_lang[i].version_command, &output, &ignored, NULL, NULL); } else { - found = g_spawn_command_line_sync(detect_lang[i].version_command, NULL, &output, NULL, NULL); + found = g_spawn_command_line_sync(detect_lang[i].version_command, &ignored, &output, NULL, NULL); } + g_free(ignored); if (found) { regex = g_regex_new(detect_lang[i].regex, 0, 0, NULL); -- cgit v1.2.3