branch: elpa/crux commit f258bef9bb09d93087b910868d3af3277f223205 Author: Kasim <onen...@users.noreply.github.com> Commit: GitHub <nore...@github.com>
Fix `sudo` not found error in OpenBSD and Alpine Linux (#93) This comes handy for OpenBSD or Alpine linux users where doas is the replacement of sudo. --- CHANGELOG.md | 2 +- crux.el | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 518ed8a3c4..2d98ae2d78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,5 +30,5 @@ * Fixed extra line issue when duplicating region. * Various small fixes that we were too lazy to document properly. - +* Fixed `sudo` not found in OpenBSD and Alpine Linux ## 0.3.0 (2016-05-31) diff --git a/crux.el b/crux.el index f39cc581fc..526b611b02 100644 --- a/crux.el +++ b/crux.el @@ -554,7 +554,9 @@ See `file-attributes' for more info." (remote-host (file-remote-p default-directory 'host)) (remote-localname (file-remote-p filename 'localname))) (find-alternate-file (format "/%s:root@%s:%s" - (or remote-method "sudo") + (or remote-method (if (executable-find "doas") + "doas" + "sudo")) (or remote-host "localhost") (or remote-localname filename))))) @@ -571,7 +573,9 @@ buffer is not visiting a file." (remote-host (file-remote-p default-directory 'host)) (remote-localname (file-remote-p default-directory 'localname))) (find-file (format "/%s:root@%s:%s" - (or remote-method "sudo") + (or remote-method (if (executable-find "doas") + "doas" + "sudo")) (or remote-host "localhost") (or remote-localname (read-file-name "Find file (as root): ")))))