[gimp/gimp-2-10] app: when interpreter not found in interpreter DB, leave shebang as-is.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: when interpreter not found in interpreter DB, leave shebang as-is.
- Date: Wed, 30 Oct 2019 12:56:48 +0000 (UTC)
commit 0b49a26d6a7c90feed9b3a59fe8bd26672ebb968
Author: Jehan <jehan girinstud io>
Date: Mon Jul 29 14:01:46 2019 +0200
app: when interpreter not found in interpreter DB, leave shebang as-is.
In particular, if the shebang is `#!/usr/bin/env lang` and we have not
registered a specific interpreter for `lang`, the system should leave
the env tool search the right interpreter for us. We only bypass env
when we set our own explicit interpreter.
(cherry picked from commit 9e844ae1d74990b5b2495bb5dea95d0f9bc0d130)
Slight modification from master commit: not applying to
palette-to-gradient.py plug-in.
app/plug-in/gimpinterpreterdb.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/app/plug-in/gimpinterpreterdb.c b/app/plug-in/gimpinterpreterdb.c
index 4d9b785ece..14b1f7905d 100644
--- a/app/plug-in/gimpinterpreterdb.c
+++ b/app/plug-in/gimpinterpreterdb.c
@@ -721,14 +721,22 @@ resolve_sh_bang (GimpInterpreterDB *db,
{
if (strcmp ("/usr/bin/env", name) == 0)
{
- /* Shift program name and arguments to the right. */
- name = cp;
+ program = g_hash_table_lookup (db->programs, cp);
- for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++)
- ;
+ if (program)
+ {
+ /* Shift program name and arguments to the right, if and
+ * only if we recorded a specific interpreter for such
+ * script. Otherwise let `env` tool do its job.
+ */
+ name = cp;
+
+ for ( ; *cp && (*cp != ' ') && (*cp != '\t'); cp++)
+ ;
- while ((*cp == ' ') || (*cp == '\t'))
- *cp++ = '\0';
+ while ((*cp == ' ') || (*cp == '\t'))
+ *cp++ = '\0';
+ }
}
if (*cp)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]