File: executable.el.html
executable.el is used by certain major modes to insert a suitable
#! line at the beginning of the file, if the file does not already
have one.
Unless it has a magic number, a Unix file with executable mode is passed to
a new instance of the running shell (or to a Bourne shell if a csh is
running and the file starts with :). Only a shell can start such a file,
exec() cannot, which is why it is important to have a magic number in every
executable script. Such a magic number is made up by the characters #!
the filename of an interpreter (in COFF, ELF or somesuch format) and one
optional argument.
This library is for certain major modes like sh-, awk-, perl-, tcl- or makefile-mode to insert or update a suitable #! line at the beginning of the file, if the file does not already have one and the file is not a default file of that interpreter (like .profile or makefile). It also makes the file executable if it wasn't, as soon as it's saved.
It also allows debugging scripts, with an adaptation of compile, as far as interpreters give out meaningful error messages.
Modes that use this should nconc executable-map to the end of their own
keymap and executable-font-lock-keywords to the end of their own font
lock keywords. Their mode-setting commands should call
executable-set-magic.
Defined variables (10)
executable-binary-suffixes | List of suffixes to try to find executable file names. |
executable-chmod | After saving, if the file is not executable, set this mode. |
executable-error-regexp-alist | Alist of regexps used to match script errors. |
executable-font-lock-keywords | Rules for highlighting executable scripts’ magic number. |
executable-insert | Non-nil means offer to add a magic number to a file. |
executable-magicless-file-regexp | On files with this kind of name no magic is inserted or changed. |
executable-prefix | Interpreter magic number prefix inserted when there was no magic number. |
executable-prefix-env | If non-nil, use "/usr/bin/env" in interpreter magic number. |
executable-query | If non-nil, ask user before changing an existing magic number. |
executable-self-display | Command you use with argument ‘-n+2’ to make text files self-display. |
Defined functions (6)
executable-chmod | () |
executable-command-find-posix-p | (&optional PROGRAM) |
executable-interpret | (COMMAND) |
executable-make-buffer-file-executable-if-script-p | () |
executable-self-display | () |
executable-set-magic | (INTERPRETER &optional ARGUMENT NO-QUERY-FLAG INSERT-FLAG) |