fish: edit: write to the real file name

When saving, resolve the path of the file being edited and use that as
real target to write to. Otherwise, if the file name is a symlink then
it will be replaced by a regular file with the new content, leaving the
old file untouched.

Extend test-edit.sh to check for this situation.
This commit is contained in:
Pino Toscano
2014-09-01 11:46:57 +02:00
parent ca9930ef16
commit 431cdfd983
2 changed files with 25 additions and 2 deletions

View File

@@ -43,6 +43,12 @@ cat /file.txt
stat /file.txt | grep mode:
stat /file.txt | grep uid:
stat /file.txt | grep gid:
echo ==========
write /file-2.txt "symlink test\n"
ln-s /file-2.txt /symlink-2.txt
edit /symlink-2.txt
is-symlink /symlink-2.txt
cat /symlink-2.txt
EOF
)
@@ -51,7 +57,11 @@ second line of text
mode: 33152
uid: 10
gid: 11" ]; then
gid: 11
==========
true
symlink test
second line of text" ]; then
echo "$0: error: output of guestfish after edit command did not match expected output"
echo "$output"
exit 1