summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorEnrico Jorns <ejo@pengutronix.de>2015-11-04 14:57:05 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-05 09:16:12 +0100
commit867b30a0a04b770bff328cc7170615224f80afeb (patch)
tree159d9352fe5037cc19008ccb59ea144f7923a1cd /commands
parent79f04b235c5d161deea7eed01706d5fd3d0416e9 (diff)
downloadbarebox-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.c5
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};