[gimp] app: when interpreter not found in interpreter DB, leave shebang as-is.



commit 9e844ae1d74990b5b2495bb5dea95d0f9bc0d130
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.
    
    Apply this to palette-to-gradient.py plug-in.

 app/plug-in/gimpinterpreterdb.c        | 20 ++++++++++++++------
 plug-ins/python/palette-to-gradient.py |  2 +-
 2 files changed, 15 insertions(+), 7 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)
diff --git a/plug-ins/python/palette-to-gradient.py b/plug-ins/python/palette-to-gradient.py
index 78e10c1216..3fdc54aa0a 100644
--- a/plug-ins/python/palette-to-gradient.py
+++ b/plug-ins/python/palette-to-gradient.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]