emacs-devel
[Top][All Lists]
Advanced

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

Re: executable-set-magic update


From: Andrew L. Moore
Subject: Re: executable-set-magic update
Date: Sat, 10 Jun 2017 15:31:04 -0400

> On Jun 10, 2017, at 3:17 AM, Eli Zaretskii <address@hidden> wrote:
> 
>> From: "Andrew L. Moore" <address@hidden>
>> Date: Fri, 9 Jun 2017 17:31:30 -0400
>> 
>> lisp/progmodes/executable.el does not appear to support magic numbers of the 
>> form `#/usr/bin/env interpreter’.  One way to extend support is via the 
>> attached diff which merely adds a new variable 
>> `executable-interpreter-path-absolute’.  Set the new variable to nil and 
>> variable `executable-prefix’ to “#!/usr/bin/env “.
> 
> Thanks.
> 
> Wouldn't it be more elegant (and perhaps also safer, security-wise) if
> we supported the special prefix "/usr/bin/env" directly, i.e. without
> feeding it via some kind of "back door", and allowing arbitrary
> strings there?

Attached below is a patch following your suggestions. From NEWS:

** The new variable 'executable-prefix-env' affects the format of
the magic number inserted by 'executable-set-magic'. If non-nil,
the magic number takes the form "#!/usr/bin/env interpreter",
otherwise "#!/path/to/interpreter", which is the default.

+++

As you advised, if ‘executable-prefix’ has been customized to 
something other than “#!” or “#!/usr/bin/env”, it masks the effect of
‘executable-prefix-env’. This behavior is not documented. Instead,
the doc string for ‘executable-prefix’  now adds:

 “… Use of `executable-prefix' is deprecated in favor of 
`executable-prefix-env’."

> If your proposal is accepted, I think at least its documentation parts
> should be improved:
> 
>> +(defcustom executable-interpreter-path-absolute t
>> +  "If non-nil, `executable-set-magic' uses the interpreter's
>> +absolute path. Otherwise, it's basename is used."
> 
> This doc string leaves out the important stuff: the reason why the
> variable is introduced and how it should be used.  I think the doc
> string should be more helpful by explicitly describing its intended
> usage.

New name and new definition:

(defcustom executable-prefix-env nil
  "If non-nil, the magic number inserted by function `executable-set-magic'
takes the form \"#!/usr/bin/env interpreter\", otherwise
\"#!/path/to/interpreter\"."
  :version "26.1"
  :type 'boolean
  :group 'executable)

> 
>> +  :version "26.0"
> 
> Emacs never releases N.0 versions, so this should be "26.1”.

Okay.

> 
>> @@ -220,6 +226,9 @@ executable-set-magic
>>                          (and argument (string< "" argument) " ")
>>                          argument))
> 
> The doc string of executable-set-magic should mention the variable you
> introduce.

Done - although just by changing a reference from ‘executable-prefix’ to
‘executable-prefix-env’ - i.e., ‘executable-prefix’ is now not referenced in its
deprecated role.


> Finally, there should be a NEWS entry about this new facility.

Thank you!
-AM

Attachment: lisp_progmodes_executable.el.diff
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]