From: Walter Alejandro Iglesias Subject: Re: Fix for vi editing mode in sftp(1) (PING) To: Stuart Henderson Cc: tech@openbsd.org Date: Mon, 19 Jan 2026 22:39:35 +0100 On Mon, Jan 19, 2026 at 08:16:28PM +0000, Stuart Henderson wrote: > well, &editor is obviously not set directly by that el_set. > > if el_get() returns failure before it sets &editor (for whatever > reason), editor contains garbage, so dereferencing that won't do > anything good. > I don't follow what you're telling me here. If your concern is the "editor" variable not to be initialized, we can do the following: Index: sftp.c =================================================================== RCS file: /cvs/src/usr.bin/ssh/sftp.c,v diff -u -p -u -p -r1.247 sftp.c --- sftp.c 13 Oct 2025 00:54:29 -0000 1.247 +++ sftp.c 19 Jan 2026 21:08:59 -0000 @@ -2204,6 +2204,7 @@ interactive_loop(struct sftp_conn *conn, char *remote_path; char *dir = NULL, *startdir = NULL; char cmd[2048]; + const char *editor = "emacs"; int err, interactive; EditLine *el = NULL; History *hl = NULL; @@ -2220,7 +2221,7 @@ interactive_loop(struct sftp_conn *conn, el_set(el, EL_HIST, history, hl); el_set(el, EL_PROMPT, prompt); - el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_EDITOR, editor); el_set(el, EL_TERMINAL, NULL); el_set(el, EL_SIGNAL, 1); el_source(el, NULL); @@ -2239,6 +2240,11 @@ interactive_loop(struct sftp_conn *conn, el_set(el, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL); /* make ^w match ksh behaviour */ el_set(el, EL_BIND, "^w", "ed-delete-prev-word", NULL); + + /* Vi command mode */ + el_get(el, EL_EDITOR, &editor); + if (editor[0] == 'v') + el_set(el, EL_BIND, "^[", "vi-command-mode", NULL); } if ((remote_path = sftp_realpath(conn, ".")) == NULL)