mirror of
https://github.com/slicer69/doas
synced 2024-07-09 03:55:50 +00:00
Fixed doasedit to properly handle files which start with a dash
character, such as "-bar.txt".
This commit is contained in:
parent
10ca176f40
commit
e595a0d397
15
doasedit
15
doasedit
|
@ -14,7 +14,7 @@ fi
|
||||||
|
|
||||||
if [ ! -f "$1" ]
|
if [ ! -f "$1" ]
|
||||||
then
|
then
|
||||||
echo "File does not exist or is a special file/link."
|
echo "File $1 does not exist or is a special file/link."
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ then
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp "$1" "$temp_file"
|
mydir=$(dirname -- "$1")
|
||||||
|
cp "$mydir/$1" "$temp_file"
|
||||||
if [ ! $? ]
|
if [ ! $? ]
|
||||||
then
|
then
|
||||||
echo "Unable to copy file $1"
|
echo "Unable to copy file $1"
|
||||||
|
@ -62,7 +63,7 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check to see if the file has been changed.
|
# Check to see if the file has been changed.
|
||||||
cmp -s "$1" "$temp_file"
|
cmp -s "$mydir/$1" "$temp_file"
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status -eq 0 ]
|
if [ $status -eq 0 ]
|
||||||
then
|
then
|
||||||
|
@ -74,16 +75,16 @@ fi
|
||||||
# At this point the file has been changed. Make sure it still exists.
|
# At this point the file has been changed. Make sure it still exists.
|
||||||
if [ -f "$temp_file" ]
|
if [ -f "$temp_file" ]
|
||||||
then
|
then
|
||||||
doas cp "$temp_file" "$1"
|
doas cp "$temp_file" "$mydir/$1"
|
||||||
cmp -s "$temp_file" "$1"
|
cmp -s "$temp_file" "$mydir/$1"
|
||||||
status=$?
|
status=$?
|
||||||
# If file fails to copy, do not do clean-up
|
# If file fails to copy, do not do clean-up
|
||||||
while [ $status -ne 0 ]
|
while [ $status -ne 0 ]
|
||||||
do
|
do
|
||||||
echo "Copying file back to $1 failed. Press Ctrl-C to abort or Enter to try again."
|
echo "Copying file back to $1 failed. Press Ctrl-C to abort or Enter to try again."
|
||||||
read abc
|
read abc
|
||||||
doas cp "$temp_file" "$1"
|
doas cp "$temp_file" "$mydir/$1"
|
||||||
cmp -s "$temp_file" "$1"
|
cmp -s "$temp_file" "$mydir/$1"
|
||||||
status=$?
|
status=$?
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user