From 7300c7a8130739a45396733784a8a4ef347e9f98 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Thu, 9 Nov 2023 03:18:12 +0100 Subject: [PATCH] Add sudo for readlink calls in edit --- .bin/edit | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.bin/edit b/.bin/edit index e6f6435..c7710c8 100755 --- a/.bin/edit +++ b/.bin/edit @@ -22,16 +22,20 @@ _pre_checks_file() { fi } +_readlink() { + sudo readlink -fn "$1" +} + _get_edit_directory() { target_dir=$(dirname "$1") - edit_dir_sub=$(readlink -fn "$target_dir" | md5sum | awk '{ print $1 }') + edit_dir_sub=$(_readlink "$target_dir" | md5sum | awk '{ print $1 }') edit_directory="$edit_dir_base/$edit_dir_sub/" echo "$edit_directory" } _get_edit_file() { - target=$(readlink -fn "$1") + target=$(_readlink "$1") target_name=$(basename "$target") edit_directory=$(_get_edit_directory "$target") @@ -40,7 +44,7 @@ _get_edit_file() { } _prepare_for_edit() { - target=$(readlink -fn "$1") + target=$(_readlink "$1") _pre_checks_file "$target"