fish: edit: return 1 for unchanged file

Change the return value of edit_file_editor to 1, in case the editor did
not change the (temporary) file.
This commit is contained in:
Pino Toscano
2014-08-28 10:45:28 +02:00
parent f79ee54722
commit c9b6c8dac1
3 changed files with 4 additions and 3 deletions

View File

@@ -60,5 +60,5 @@ run_edit (const char *cmd, size_t argc, char *argv[])
r = edit_file_editor (g, remotefilename, editor, NULL);
return r;
return r == -1 ? -1 : 0;
}

View File

@@ -101,7 +101,7 @@ edit_file_editor (guestfs_h *g, const char *filename, const char *editor,
/* Changed? */
if (oldstat.st_ctime == newstat.st_ctime &&
oldstat.st_size == newstat.st_size)
return 0;
return 1;
/* Upload to a new file in the same directory, so if it fails we
* don't end up with a partially written file. Give the new file

View File

@@ -26,7 +26,8 @@
* If 'backup_extension' is not null, then a copy of 'filename' is saved
* with 'backup_extension' appended to its file name.
*
* Returns -1 for failure, 0 otherwise.
* Returns -1 for failure, 0 on success, 1 if the editor did not change
* the file (e.g. the user closed the editor without saving).
*/
extern int edit_file_editor (guestfs_h *g, const char *filename,
const char *editor, const char *backup_extension);