nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 4399b734db0280ce8859376aca28ae4aa7f7d252
parent b9581bd50a82835645f8702b9d4687307cb7da6d
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 31 Mar 2019 20:05:30 +0200

bindings: disallow executing an external command when in view mode

Otherwise the user could do something like

  ^R^X  sed -i 's/a/surprise!/g' name-of-current-file  <Enter>

and the file being viewed would be modified anyway.

Diffstat:
Msrc/global.c | 4++--
Msrc/rcfile.c | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/global.c b/src/global.c @@ -1039,7 +1039,7 @@ void shortcut_init(void) N_("No Conversion"), WITHORSANS(convert_gist), TOGETHER, NOVIEW); /* Command execution is only available when not in restricted mode. */ - if (!ISSET(RESTRICTED)) { + if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) { add_to_funcs(flip_execute, MINSERTFILE, N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW); @@ -1331,7 +1331,7 @@ void shortcut_init(void) add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0); /* Only when not in restricted mode, allow Appending, Prepending, * making backups, and executing a command. */ - if (!ISSET(RESTRICTED)) { + if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) { add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0); add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0); add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0); diff --git a/src/rcfile.c b/src/rcfile.c @@ -462,7 +462,7 @@ void parse_binding(char *ptr, bool dobind) menu = menu & (is_universal(newsc->func) ? MMOST : mask); if (!menu) { - if (!ISSET(RESTRICTED)) + if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr); goto free_things;