tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: handle #! /usr/bin/env



Okay, sorry to develop this on the mailing list but I got a new update.
I'm mainly interested in comments about the idea.  I think it saves a
lot of hassle.

1{ /env -i/!s|^#![[:space:]]*/usr/bin/env|#!|;}


--- replace-interpreter.mk-orig 2013-03-02 09:29:51.000000000 -0500
+++ replace-interpreter.mk      2013-03-03 10:53:24.000000000 -0500
@@ -99,7 +99,7 @@
        cd ${WRKSRC};                                                   \
        for f in ${REPLACE_FILES.${_lang_}}; do                         \
                if [ -f "$${f}" ]; then                                 \
-                       ${SED} -e
'1s|^#![[:space:]]*${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|'
\
+                       ${SED} -e '1{ /env
-i/!s|^#![[:space:]]*/usr/bin/env|#!|;}' -e
'1s|^#![[:space:]]*${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|'
\
                        < "$${f}" > "$${f}.new";                        \
                        if [ -x "$${f}" ]; then                         \
                                ${CHMOD} a+x "$${f}.new";               \


On Sun, Mar 3, 2013 at 10:45 AM, matthew sporleder 
<msporleder%gmail.com@localhost> wrote:
> Okay I got a hint in chat:
>
> /env -i/,1!s|^#![[:space:]]*/usr/bin/env|#!|
>
> ----
>
> --- replace-interpreter.mk-orig 2013-03-02 09:29:51.000000000 -0500
> +++ replace-interpreter.mk      2013-03-03 10:44:46.000000000 -0500
> @@ -99,7 +99,7 @@
>         cd ${WRKSRC};                                                   \
>         for f in ${REPLACE_FILES.${_lang_}}; do                         \
>                 if [ -f "$${f}" ]; then                                 \
> -                       ${SED} -e
> '1s|^#![[:space:]]*${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|'
> \
> +                       ${SED} -e '/env
> -i/,1!s|^#![[:space:]]*/usr/bin/env|#!|' -e
> '1s|^#![[:space:]]*${REPLACE.${_lang_}.old}|#!${REPLACE.${_lang_}.new}|'
> \
>                         < "$${f}" > "$${f}.new";                        \
>                         if [ -x "$${f}" ]; then                         \
>                                 ${CHMOD} a+x "$${f}.new";               \
>
>
>
>
> On Sun, Mar 3, 2013 at 10:36 AM, matthew sporleder 
> <msporleder%gmail.com@localhost> wrote:
>> The following works:
>> '/env -i/!s|^#![[:space:]]*/usr/bin/env|#!|'
>>
>> But I don't know how to retain the address (1).
>>
>> Can anyone better with sed give me a hint?
>>
>> On Sun, Mar 3, 2013 at 12:18 AM, OBATA Akio <obache%netbsd.org@localhost> 
>> wrote:
>>> There is a worry that dropping `env -i' may introduce security risks
>>> (but it should be fixed to not depend on `env -i').
>>>
>>>
>>> On Sun, 03 Mar 2013 13:55:47 +0900, matthew sporleder 
>>> <msporleder%gmail.com@localhost>
>>> wrote:
>>>
>>>> I think this sed should handle it:
>>>> -e
>>>> '1s|^#![[:space:]]*/[^/]*/bin/env[[:space:]]*-*[[:alpha:]]*[[:space:]]|#!|'
>>>>
>>>> I'd appreciate a second look.
>>>>
>>>> On Sat, Mar 2, 2013 at 8:33 PM, matthew sporleder 
>>>> <msporleder%gmail.com@localhost>
>>>> wrote:
>>>>>
>>>>> I'd have to adjust the sed for that one.  I will work on it a little
>>>>> more tomorrow unless someone beats me to it.
>>>>>
>>>>> On Sat, Mar 2, 2013 at 8:22 PM, OBATA Akio <obache%netbsd.org@localhost> 
>>>>> wrote:
>>>>>>
>>>>>> for the case using /usr/bin/env with `-i'?
>>>>>>
>>>>>> --
>>>>>> OBATA Akio / obache%NetBSD.org@localhost
>>>>
>>>>
>>>
>>>
>>> --
>>> OBATA Akio / obache%NetBSD.org@localhost


Home | Main Index | Thread Index | Old Index