diff options
author | Enrico Jorns <ejo@pengutronix.de> | 2015-11-04 14:57:05 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-05 09:16:12 +0100 |
commit | 867b30a0a04b770bff328cc7170615224f80afeb (patch) | |
tree | 159d9352fe5037cc19008ccb59ea144f7923a1cd /commands | |
parent | 79f04b235c5d161deea7eed01706d5fd3d0416e9 (diff) | |
download | barebox-867b30a0a04b770bff328cc7170615224f80afeb.tar.gz barebox-867b30a0a04b770bff328cc7170615224f80afeb.tar.xz |
edit: return error when save_file failed
When writing a file failed (e.g. due to a read-only file system), no
error was reported by the 'edit' tool. To be valid (and to not confuse
the poor user) at least '1' should be returned to indicate an error.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/edit.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/commands/edit.c b/commands/edit.c index af3338affa..c014892fc4 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -384,6 +384,7 @@ static int do_edit(int argc, char *argv[]) int i; int linepos; int c; + int ret = COMMAND_SUCCESS; if (argc != 2) return COMMAND_ERROR_USAGE; @@ -542,7 +543,7 @@ static int do_edit(int argc, char *argv[]) } break; case 4: - save_file(argv[1]); + ret = save_file(argv[1]); goto out; case 3: goto out; @@ -555,7 +556,7 @@ out: free_buffer(); printf("%c[2J%c[r", 27, 27); printf("\n"); - return 0; + return ret; } static const char *edit_aliases[] = { "sedit", NULL}; |