[PATCH master] edit: don't change terminal mode if sedit would fail to read file
Ahmad Fatoum
ahmad at a3f.at
Sat Apr 10 12:02:50 BST 2021
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 at a3f.at>
---
commands/edit.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/commands/edit.c b/commands/edit.c
index 3ab4beaa4ffb..f1e4e4d5c260 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;
--
2.30.0
More information about the barebox
mailing list