mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH master] edit: don't change terminal mode if sedit would fail to read file
Date: Sat, 10 Apr 2021 13:02:50 +0200	[thread overview]
Message-ID: <20210410110250.2104510-1-ahmad@a3f.at> (raw)

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>
---
 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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-04-10 11:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 11:02 Ahmad Fatoum [this message]
2021-04-13  7:23 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210410110250.2104510-1-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox