Next: Timestamps, Previous: Copyrights, Up: Top [Contents][Index]

## 8 Making Interpreter Scripts Executable

Various interpreter modes such as Shell script mode or AWK mode will automatically insert or update the buffer’s magic number, a special comment on the first line that makes the `exec` systemcall know how to execute the script. To this end the script is automatically made executable upon saving, with `executable-chmod` as argument to the system `chmod` command. The magic number is prefixed by the value of `executable-prefix`.

Any file whose name matches `executable-magicless-file-regexp` is not furnished with a magic number, nor is it made executable. This is mainly intended for resource files, which are only meant to be read in.

The variable `executable-insert` says what to do when `executable-set-magic` is called non-interactively, e.g., when file has no or the wrong magic number:

`nil`

  Do nothing.

`t`

  Insert or update magic number.

other

  Insert or update magic number, but mark as unmodified.

The variable `executable-query` controls whether to ask about inserting or updating the magic number. When this is `nil` updating is only done with `M-x executable-set-magic`. When this is `function` you are queried whenever `executable-set-magic` is called as a function, such as when Emacs puts a buffer in Shell script mode. Otherwise you are always queried.