From 1cbc5784074d4b12bffac36b4955949f7488dfea Mon Sep 17 00:00:00 2001 From: Marcel Robitaille Date: Mon, 10 Oct 2022 11:50:38 -0300 Subject: [PATCH] [bin] Fix sudoedit when file doesn't exist yet --- bin/sudoedit | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/sudoedit b/bin/sudoedit index 4ef3a58..60265e1 100755 --- a/bin/sudoedit +++ b/bin/sudoedit @@ -1,8 +1,12 @@ #!/bin/zsh tmp="$(mktemp /tmp/sudoedit_XXXXXXXXXXXX_$(basename $1))" +touch "$tmp" + +if [ -f "$1" ]; then + sudo cat "$1" > "$tmp" +fi -sudo cat "$1" > "$tmp" inotifywait -m "$tmp" -e create -e moved_to -e close_write 2>/dev/null > \ >(sudo sh -c "while read path action file; do cp '$tmp' '$1'; done") &