Search code examples
filecronbuffernano

Prevent nano from creating save-file when SIGHUP or SIGTERM is received


G'day

The text editor nano has this feature, that creates a save-file when the editor receives a SIGHUP or SIGTERM or runs out of memory.

In this case nano writes the current editor content to a temporary file called nano.save or, if editing an existing file, nano is adding the .save suffix to this filename: filename.save.

Basically this is a great feature. The problem is, that I am editing files in /etc/cron.d/ with nano and therefore find a lot of *.save-files in this folder.

So this eventually leads to double cron jobs.

So my questions are:

  1. Is there a way to prevent nano from saving those buffers to the filesystem?

  2. Or is it possible to change the folder of those files to another, fixed location?

  3. Or is there another way to tell cron to not run files containing /.save/

Thanks in advance


Solution

  • According to the man page: https://www.nano-editor.org/dist/v2.2/nano.1.html

    −R (−−restricted) Restricted mode: don’t read or write to any file not specified on the command line; read any nanorc files; allow suspending; allow a file to be appended to, prepended to, or saved under a different name if it already has one; or use backup files or spell checking. Also accessible by invoking nano with any name beginning with ’r’ (e.g. "rnano").

    So one solution is to simply use "rnano" or "nano -R" instead.