3 lines
1.2 KiB
Plaintext
3 lines
1.2 KiB
Plaintext
<p>Bozhidar Batsov has a splendid tip over at <a href="https://emacsredux.com">Emacs Redux</a>. I’m pretty sure he’s mentioned it before but it’s so useful it bears repeating. The tip is <a href="https://emacsredux.com/blog/2021/09/29/make-script-files-executable-automatically/">how to make scripts executable</a>. “Scripts” means a file that has a shebang line. That is, a line that starts with <code>#!</code> followed by an application to execute.</p>
|
||
<p>The usual workflow is to write the script, save the file, and then change its permissions to make it executable. But it turns out that Emacs provides a better—or at least easier—way. The trick is to use the <code>executable-make-buffer-file-executable-if-script-p</code> command. It checks for the shebang line, makes sure that no execute bits are already set, and if not sets the execute bits respecting the umask.</p>
|
||
<p>The usual procedure is to call <code>executable-make-buffer-file-executable-if-script-p</code> from a hook function as described by Batsov in his post. If you’ve every written a script and tried to run it only to discover that it’s not executable, this tip will save you some time and frustration.</p> |