diff options
author | Burt P <pburt0@gmail.com> | 2017-07-13 01:35:52 -0500 |
---|---|---|
committer | Leandro Pereira <leandro@hardinfo.org> | 2017-07-19 07:20:33 -0700 |
commit | 2ad7b03874a7dd196ff15e4a0834688b47ca373c (patch) | |
tree | ab33521403c7fe0a395b2b6a03a9d0d130b27786 | |
parent | a8d118a91d1cef9cdcabda8d55240bb332a4569a (diff) |
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 <pburt0@gmail.com>
-rw-r--r-- | modules/computer.c | 13 |
1 files changed, 9 insertions, 4 deletions
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); |