[PATCH cygport] Improve __fix_shebang()
Lemures Lemniscati
lemures.lemniscati@gmail.com
Mon Jan 25 15:17:11 GMT 2021
Hi!
This is a patch for improving __fix_shebang(),
in case a shebang uses 'env'.
(just gobbling a word after 'env')
diff --git a/lib/src_install.cygpart b/lib/src_install.cygpart
index cca7347..d101f5b 100644
--- a/lib/src_install.cygpart
+++ b/lib/src_install.cygpart
@@ -103,7 +103,9 @@ __fix_shebang() {
continue
fi
- sed -i -e "s|#! */[^ ]*\(.*\)|#! ${interp}\1|" ${x}
+ # Note: This pattern does not work when 'env' with
+ # any option or any variable-setting.
+ sed -i -e 's;^#![[:space:]]*\(\([^[:space:]]*/\|\)env[[:space:]]*[^[:space:]][^[:space:]]*\|[^[:space:]]*\)\(.*\);#!'"${interp}"'\3;' ${x}
done
}
--
2.30.0
A test script for the same pattern is attached as a.sh
Regards,
Lem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: a.sh
Type: application/octet-stream
Size: 544 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin-apps/attachments/20210126/d92131b6/attachment.obj>
More information about the Cygwin-apps
mailing list