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
|
mkdir -p /tmp/doasedit/$destfile_pfx
|
||||||
srcfile="$(realpath $1)"
|
srcfile="$(realpath $1)"
|
||||||
|
|
||||||
doas cp $srcfile /tmp/doasedit/$destfile_pfx/edit
|
if [ -f "$srcfile" ]; then
|
||||||
doas chown -R $USER:$USER /tmp/doasedit/$destfile_pfx/edit
|
doas cp $srcfile /tmp/doasedit/$destfile_pfx/edit
|
||||||
doas cp $srcfile /tmp/doasedit/$destfile_pfx/file
|
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
|
$EDITOR /tmp/doasedit/$destfile_pfx/edit
|
||||||
|
|
||||||
|
|
||||||
cat /tmp/doasedit/$destfile_pfx/edit | doas tee /tmp/doasedit/$destfile_pfx/file 1>/dev/null
|
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
|
if cmp -s "/tmp/doasedit/$destfile_pfx/file" "$srcfile"; then
|
||||||
|
Loading…
Reference in New Issue
Block a user