diff --git a/zsh/.config/zsh/functions.zsh b/zsh/.config/zsh/functions.zsh index 8a8edac..5fa480a 100644 --- a/zsh/.config/zsh/functions.zsh +++ b/zsh/.config/zsh/functions.zsh @@ -1,19 +1,18 @@ doasedit() { (( ${+commands[doas]} )) || return 1 - - doas -L - - 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 + doas -u root sh -c \ + "cp /etc/doas.conf /tmp/doas.conf \ + && $EDITOR /tmp/doas.conf \ + && doas -C /tmp/doas.conf \ + && mv /tmp/doas.conf /etc/doas.conf \ + && echo 'ok' \ + || echo >&2 'error'" + local STATUS=$? + doas -L + + [[ $STATUS -gt 0 ]] && return 1 } get_ip() {