From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id s4CvEW04e2g0JBgAWB0awg (envelope-from ) for ; Sat, 19 Jul 2025 02:17:17 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qN7R0uNH; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ahl+7PHl; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qN7R0uNH; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ahl+7PHl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 134731E11C; Sat, 19 Jul 2025 02:17:17 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F33A41E0C2 for ; Sat, 19 Jul 2025 02:17:15 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 72B7A3858401 for ; Sat, 19 Jul 2025 06:17:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72B7A3858401 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qN7R0uNH; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ahl+7PHl; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=qN7R0uNH; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=Ahl+7PHl Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 568313858D33 for ; Sat, 19 Jul 2025 06:16:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 568313858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 568313858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752905797; cv=none; b=IBn8qlwKdSzbCbZUz0e/QeW+RCZy7p1/a2ScDZ6ABIyVBt9yTpmn0q27Od6z7BvhYmxb2zQxDqy6HUBCegYXT9qXN1r65LKxOvZXlNjq6cIVIsksoq5BItmW6zZubu46wBG3QqBVx7U8+lQ1guS9FR92VOoJqOamsGHl9FQz7jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1752905797; c=relaxed/simple; bh=mSRtCI9dcOO4Uq6pIxtzeKXsLGxUJ6eQvOlQRE2reYA=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=hZwNcaKUMc1l7s8RBTvHxUs/AR771lVnI10l4nSOh3wCGQT7DbzEWuWH1voHcDJXdqHpw+KpdcXIoOdJMFFisND4bcoMvDU7Ww5wT+HCLmLnNOAbc5p2ezc+f2Zrq+2/DBycGL64R1D+KiMlLsYvC1KKYEr8wT8HVIN/Zte+TxQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 568313858D33 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3F8692122F for ; Sat, 19 Jul 2025 06:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1752905796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LwruHw5dHjwl+9TyJB4wfZfl2gDThhJdGHlKmOA8bz8=; b=qN7R0uNHkJDNkO7HVAl0ub6thcovvvZZnpDVQmRLZmlbQ2dIX/9JFVzPVnCY6g7pN2FsuB Uqim37Gaxhp4ktIetFRt1DzI0P/K73Xh70P4xT9sh9niG+EZrIBShnqsy4k1CV/mQLB5Rx knZGI6FXftJfNUcu216VrHbQFgge4Oo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1752905796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LwruHw5dHjwl+9TyJB4wfZfl2gDThhJdGHlKmOA8bz8=; b=Ahl+7PHllMA8vnz899n5QE5JYk1XI/OR/rApDFaikECeFkhJWo2/DAHh2VXoaZcwAnkfl1 QfTgPwF1LytJjaCQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1752905796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LwruHw5dHjwl+9TyJB4wfZfl2gDThhJdGHlKmOA8bz8=; b=qN7R0uNHkJDNkO7HVAl0ub6thcovvvZZnpDVQmRLZmlbQ2dIX/9JFVzPVnCY6g7pN2FsuB Uqim37Gaxhp4ktIetFRt1DzI0P/K73Xh70P4xT9sh9niG+EZrIBShnqsy4k1CV/mQLB5Rx knZGI6FXftJfNUcu216VrHbQFgge4Oo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1752905796; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LwruHw5dHjwl+9TyJB4wfZfl2gDThhJdGHlKmOA8bz8=; b=Ahl+7PHllMA8vnz899n5QE5JYk1XI/OR/rApDFaikECeFkhJWo2/DAHh2VXoaZcwAnkfl1 QfTgPwF1LytJjaCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 25978136A8 for ; Sat, 19 Jul 2025 06:16:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 775KB0Q4e2iBHQAAD6G6ig (envelope-from ) for ; Sat, 19 Jul 2025 06:16:36 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/cli] Document \001 and \002 usage for set prompt Date: Sat, 19 Jul 2025 08:16:36 +0200 Message-ID: <20250719061636.11460-1-tdevries@suse.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org PR cli/28887 reports the following problem when using a custom prompt. First, we set up the custom prompt (with ^ marking the position of the blinking cursor on the line above): ... $ gdb -q -ex "set prompt \033[31mgdb$ \033[0m" gdb$ ^ ... Then we type some string, and enter it into the command history: ... gdb$ some long command ❌️ Undefined command: "some". Try "help". gdb$ ^ ... We use C-p to fetch the previous command: ... gdb$ some long command ^ ... Sofar, so good. Finally, we use C-a which should move the cursor to just after the prompt, but instead we get: ... gdb$ some long command ^ ... This is fixed by using \001 and \002: ... (gdb) set prompt \001\033[31m\002gdb$ \001\033[0m\002 ... aka as RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE [1]. Add an example to the documentation showing the use of these markers. The added example is the equivalent of the "\[\e[0;34m\](gdb)\[\e[0m\]" example documented at gdb.prompt.substitute_string that can be used with "set extended-prompt". While working on this, I noticed that "show prompt" doesn't show back the original string, using '\e' instead of '\033': ... gdb$ show prompt Gdb's prompt is "\001\e[31m\002gdb$ \001\e[0m\002". ... and that the shown string can't be used as an argument to "set prompt": ... gdb$ set prompt \001\e[31m\002gdb$ \001\e[0m\002 e[31mgdb$ e[0m ... I've filed this as PR cli/33184. [1] https://tiswww.case.edu/php/chet/readline/readline.html --- gdb/doc/gdb.texinfo | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 35b770f8138..0a2d34756eb 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -27659,6 +27659,16 @@ or a prompt that does not. @item set prompt @var{newprompt} Directs @value{GDBN} to use @var{newprompt} as its prompt string henceforth. +For example, this will set a blue-colored ``(gdb)'' prompt: + +@smallexample +set prompt \001\033[0;34m\002(gdb)\001\033[0m\002 +@end smallexample + +It uses ``\001'' and ``\002'' to begin and end a sequence of +non-printing characters, to make sure they're not counted in the string +length. + @kindex show prompt @item show prompt Prints a line of the form: @samp{Gdb's prompt is: @var{your-prompt}} base-commit: cfbf9925c1c34f9e9d47c8b29d165866557663e3 -- 2.43.0