Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lHL4n-0003YJ-QD for mharc-grub-devel@gnu.org; Wed, 03 Mar 2021 01:33:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHL4m-0003Y7-Ds for grub-devel@gnu.org; Wed, 03 Mar 2021 01:33:40 -0500 Received: from air.basealt.ru ([194.107.17.39]:44290) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHL4k-0006AO-CQ for grub-devel@gnu.org; Wed, 03 Mar 2021 01:33:40 -0500 Received: by air.basealt.ru (Postfix, from userid 490) id 982C8589421; Wed, 3 Mar 2021 06:33:33 +0000 (UTC) Received: from [10.88.144.159] (obninsk.basealt.ru [217.15.195.17]) by air.basealt.ru (Postfix) with ESMTPSA id 82C84589423 for ; Wed, 3 Mar 2021 06:33:31 +0000 (UTC) Subject: Re: [PATCH] password: Fix backspace in username prompt To: grub-devel@gnu.org References: <20210301075840.11283-1-egori@basealt.ru> <20210301172626.abzrr7xdoiban2yk@csclub.uwaterloo.ca> From: Egor Ignatov Message-ID: Date: Wed, 3 Mar 2021 09:33:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210301172626.abzrr7xdoiban2yk@csclub.uwaterloo.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Received-SPF: pass client-ip=194.107.17.39; envelope-from=egori@basealt.ru; helo=air.basealt.ru X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2021 06:33:40 -0000 I used grub_printf 3 times, because for some reason (line wrapping I guess) if you print "\b \b" at once the backspace key doesn't work on the second last character in the terminal line. The visual cursor gets stuck there and doesn't remove characters anymore, although you can still type more. This may be irrelevant because I doubt anyone is using a username longer than one line, but it solves the problem. On 3/1/21 8:26 PM, Lennart Sorensen wrote: > On Mon, Mar 01, 2021 at 10:58:40AM +0300, Egor Ignatov wrote: >> From: Egor Ignatov >> >> Make backspace work in superuser login prompt. >> >> The problem was that bidi logical to visual ignored BN type, >> so you couldn't print control characters. >> >> Use grub_printf() 3 times, because a line wrap will cause >> the cursor to get stuck at the end of the terminal line. >> >> Resolves: #60114 >> Signed-off-by: Egor Ignatov >> --- >> grub-core/normal/auth.c | 4 +++- >> grub-core/normal/charset.c | 1 + >> grub-core/term/gfxterm.c | 11 +++++++++-- >> 3 files changed, 13 insertions(+), 3 deletions(-) >> >> diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c >> index 6be678c0d..ffbf6d890 100644 >> --- a/grub-core/normal/auth.c >> +++ b/grub-core/normal/auth.c >> @@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size) >> if (cur_len) >> { >> cur_len--; >> - grub_printf ("\b \b"); >> + grub_printf ("\b"); >> + grub_printf (" "); >> + grub_printf ("\b"); >> } >> continue; >> } > Is this the part that the commit message refers to? I must admit I > am not quite sure why this change makes a difference, but if it does, > perhaps it is important (and non obvious) enough that the code should > actually have a comment explaining it, or someone might come by and > clean it up again later. >