fix non-existent file case
This commit is contained in:
parent
cf5f037f49
commit
69fc00861e
13
doasedit
13
doasedit
@ -9,13 +9,18 @@ done
|
||||
mkdir -p /tmp/doasedit/$destfile_pfx
|
||||
srcfile="$(realpath $1)"
|
||||
|
||||
doas cp $srcfile /tmp/doasedit/$destfile_pfx/edit
|
||||
doas chown -R $USER:$USER /tmp/doasedit/$destfile_pfx/edit
|
||||
doas cp $srcfile /tmp/doasedit/$destfile_pfx/file
|
||||
if [ -f "$srcfile" ]; then
|
||||
doas cp $srcfile /tmp/doasedit/$destfile_pfx/edit
|
||||
doas chown -R $USER:$USER /tmp/doasedit/$destfile_pfx/edit
|
||||
doas cp $srcfile /tmp/doasedit/$destfile_pfx/file
|
||||
else
|
||||
# create file with "regular" system permissions (root:root 644)
|
||||
touch /tmp/doasedit/$destfile_pfx/file
|
||||
doas chown root:root /tmp/doasedit/$destfile_pfx/file
|
||||
fi
|
||||
|
||||
$EDITOR /tmp/doasedit/$destfile_pfx/edit
|
||||
|
||||
|
||||
cat /tmp/doasedit/$destfile_pfx/edit | doas tee /tmp/doasedit/$destfile_pfx/file 1>/dev/null
|
||||
|
||||
if cmp -s "/tmp/doasedit/$destfile_pfx/file" "$srcfile"; then
|
||||
|
Loading…
Reference in New Issue
Block a user