From d0fb39a307fa7cf5a4ba00c8499faa209813a7f2 Mon Sep 17 00:00:00 2001 From: theanonymousexyz Date: Fri, 27 May 2022 20:30:58 +0200 Subject: [PATCH] Add error handling to doasedit() --- zsh/.config/zsh/functions.zsh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zsh/.config/zsh/functions.zsh b/zsh/.config/zsh/functions.zsh index 4d858db..8a8edac 100644 --- a/zsh/.config/zsh/functions.zsh +++ b/zsh/.config/zsh/functions.zsh @@ -2,8 +2,17 @@ doasedit() { (( ${+commands[doas]} )) || return 1 doas -L - doas $EDITOR /etc/doas.conf - doas doas -C /etc/doas.conf && echo "ok" || echo "error" + + doas cp /etc/doas.conf /tmp/doas.conf + doas $EDITOR /tmp/doas.conf + + if doas doas -C /tmp/doas.conf; then + echo "ok" + doas mv /tmp/doas.conf /etc/doas.conf + else + echo "error" + fi + doas -L }