From: Ralph Ronnquist Date: Thu, 9 Jun 2022 03:51:00 +0000 (+1000) Subject: pass EDITOR through sudo X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=adac785b1f4ad065ce6ab15839b159050bb1ec2a;p=rrq%2Fnewlisp-ftw.git pass EDITOR through sudo --- diff --git a/enitool.lsp b/enitool.lsp index 21508a9..af06741 100755 --- a/enitool.lsp +++ b/enitool.lsp @@ -11,12 +11,13 @@ # right-arrow or return = follow to sourced file, or edit the current block # left-arrow or q = go up or exit -;(signal 2 (fn (x) (exit))) +(signal 2 (fn (x) (exit))) (when (!= "0" (if (exec "id -u") ($it 0) "")) - (let ((SUDO (if (exec "command -v sudo") ($it 0) "/usr/bin/sudo"))) - (wait-pid (process (join (cons SUDO (main-args) " "))))) - (exit 0)) + (let ((SUDO (if (exec "command -v sudo") ($it 0) "/usr/bin/sudo")) + (ED (format "env EDITOR=%s" (or (env "EDITOR") "nano"))) ) + (wait-pid (process (join (flat (list SUDO ED (main-args))) " "))) + (exit 0))) (constant ;; all "block starters", including blank lines