diff options
author | Ahmad Fatoum <ahmad@a3f.at> | 2021-04-10 13:02:50 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-04-13 09:22:48 +0200 |
commit | f630fef413ae1a941a672e6fb1890585d8270bf1 (patch) | |
tree | dc7dcbab7b662975fe1056434545ccceb84bdfbb | |
parent | 38b017d9b198e8f4fd6ad40eee3181b02b1385e4 (diff) | |
download | barebox-f630fef413ae1a941a672e6fb1890585d8270bf1.tar.gz barebox-f630fef413ae1a941a672e6fb1890585d8270bf1.tar.xz |
edit: don't change terminal mode if sedit would fail to read file
Failing to read the file, e.g. because the file is actually a directory
will normally result in an appropriate error message.
When using vi or sedit however, we change cursor position beforehand
and then directly exit, which messes up the terminal output and
can even make the shell unusable (as on my Laptop's UEFI).
Move the check earlier to avoid this.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
Link: https://lore.pengutronix.de/20210410110250.2104510-1-ahmad@a3f.at
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | commands/edit.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/commands/edit.c b/commands/edit.c index 3ab4beaa4f..f1e4e4d5c2 100644 --- a/commands/edit.c +++ b/commands/edit.c @@ -495,6 +495,10 @@ static int do_edit(int argc, char *argv[]) if (argc != 2) return COMMAND_ERROR_USAGE; + buffer = NULL; + if(edit_read_file(argv[1])) + return 1; + screenwidth = 80; /* @@ -517,10 +521,6 @@ static int do_edit(int argc, char *argv[]) is_vi = true; } - buffer = NULL; - if(edit_read_file(argv[1])) - return 1; - cursx = 0; cursy = 0; textx = 0; |