From unknown Mon Aug 18 09:02:04 2025 X-Loop: help-debbugs@gnu.org Subject: bug#70164: home-bash-service default PS1 overwrites .bashrc PS1 in login shells Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 03 Apr 2024 15:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70164 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 70164@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171215960327107 (code B ref -1); Wed, 03 Apr 2024 15:54:03 +0000 Received: (at submit) by debbugs.gnu.org; 3 Apr 2024 15:53:23 +0000 Received: from localhost ([127.0.0.1]:59377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rs2vT-000739-BG for submit@debbugs.gnu.org; Wed, 03 Apr 2024 11:53:23 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56160) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rs2vN-00071t-LY for submit@debbugs.gnu.org; Wed, 03 Apr 2024 11:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rs2vC-0004zC-Dm for bug-guix@gnu.org; Wed, 03 Apr 2024 11:53:06 -0400 Received: from mail-108-mta57.mxroute.com ([136.175.108.57]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rs2v9-0004FF-VA for bug-guix@gnu.org; Wed, 03 Apr 2024 11:53:06 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta57.mxroute.com (ZoneMTA) with ESMTPSA id 18ea4a9d36f0003bea.001 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 03 Apr 2024 15:52:56 +0000 X-Zone-Loop: 7ce23d45b14c6cd1e0be5663a205947067f132484951 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Wo3jyr2DM5vomixL4DsNZEe+yhZkWMvkIuvrIJEri9w=; b=DbYtT2+bu5e58+LLEzazhv7YlE uWGrFNe8jdXm8tHz+341YalXSmZjGh28/E4mQsIKxNQKTQKXbmuvAZYe1nwD23btYcilEElOW0W4x IuxD7FPMi4NkW9cgsMgv72ag7426DJjOAQVjtPxPUaesUqgBs0ueU7f54nd9lOQsdxmKtR4YLP5Zq wPRxbDUQfzlw2VylRv67bP0AX4cp4JjAcwlnLPbFlNiUO6W9hMEm7Qvk4AWa5I6QIFiESXrLZ+2pj pM7oq2d6x+ayLyzAHoMveqaZ7q4JeHzkfrWufcsBnwJ42mDjK1D3EnPKwfkaf7RSbzMlnz/47iveD EnXoghjw==; From: Richard Sent Date: Wed, 03 Apr 2024 11:52:47 -0400 Message-ID: <87r0fmmoj4.fsf@freakingpenguin.com> MIME-Version: 1.0 Content-Type: text/plain X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.57; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta57.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Hi Guix! A common convention for where to set PS1 is in .bashrc, not .bash_profile [1-3]. Unfortunately home-bash-service doesn't support this convention for login shells. home-bash-service generates a default .bash_profile that follows these steps: 1. Source .profile 2. Source .bashrc 3. Set PS1 if guix-defaults? is truthy This means that any PS1 configuration in .bashrc is overwritten by .bash_profile for login shells specifically. This is visible in a TTY, but also in WSL, which defaults to opening a login shell. PS1 will be Guix's predefined value instead of the value set in .bashrc. Setting guix-defaults? to #f has many side effects, so I don't feel that is a valid solution. A comment in home/serivces/shells.scm suggests setting PS1 via environment-variables since that is appended to the end of .bash_profile. This is fine for simple prompts, but complicated prompts are often split apart into separate bash functions and variables. Either an implicit dependency between .bashrc and .bash_profile is created, or .bash_profile balloons into a mega-file while the conventional wisdom is to keep it as simple as possible. environment-variables also exports PS1, causing it to become an environment variable, not a shell variable. This might cause some odd behavior when subprocesses inherit it. [4] Some possible solutions: 1. Move default PS1 to bashrc, right after serializing %default-bashrc 2. Keep default PS1 in .bash_profile, but before loading .bashrc 3. Add a set-prompt? field to home-bash-configuration Of the 3, I think 1 is the best and plan to submit a patch for it soon. I'm opening the bug in case anyone thinks I missed something. [1] https://unix.stackexchange.com/a/549075 [2] https://superuser.com/a/789465 [3] https://superuser.com/a/789454 [4] https://unix.stackexchange.com/a/44000 -- Take it easy, Richard Sent Making my computer weirder one commit at a time. From unknown Mon Aug 18 09:02:04 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Richard Sent Subject: bug#70164: closed (Re: [bug#70205] [PATCH] home: services: bash: Move default PS1 prompt to bashrc) Message-ID: References: <87mspbzvgt.fsf@gnu.org> <87r0fmmoj4.fsf@freakingpenguin.com> X-Gnu-PR-Message: they-closed 70164 X-Gnu-PR-Package: guix Reply-To: 70164@debbugs.gnu.org Date: Mon, 29 Apr 2024 21:55:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1714427702-14518-1" This is a multi-part message in MIME format... ------------=_1714427702-14518-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #70164: home-bash-service default PS1 overwrites .bashrc PS1 in login shells which was filed against the guix package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 70164@debbugs.gnu.org. --=20 70164: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D70164 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1714427702-14518-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 70164-done) by debbugs.gnu.org; 29 Apr 2024 21:54:30 +0000 Received: from localhost ([127.0.0.1]:58844 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1YxC-0003lo-FI for submit@debbugs.gnu.org; Mon, 29 Apr 2024 17:54:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46080) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1Yx7-0003lf-8H; Mon, 29 Apr 2024 17:54:29 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1Ywg-00075g-2S; Mon, 29 Apr 2024 17:53:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=XZP2uDACYxto4m5ITTutDqped5qWs6AFWZU4xS9jx0g=; b=MS4kRJRY/1T00cW4CQ/1 cGfhIBEMnuzpJCBmJKzIVZO4VXW6lHN8xCFaMO5h3zhnPVUxpKY+efHtoF6NzAtNy5C21K627UXLv fDVtF6vuGOf2Pb22fEtGZRIGcouFxnOhC/udI6Sew7P8acdblYSKZzWQRMBDuYfgiCb0/+GAsm0UE +6RIu2LQX5zl/oE1xaHewFM+5O9koO1jyk0RaceWPeN/hiZJuZ/g/wCJdbsGXWrKY9nsi0HuIwolZ vVY0tqIe4/bLgP+TqGqtiAogh9XWyczVAcLtz6c4AA5YW41bWCb23WcY1+XQqDkira7CH9m4Yz2JO a61Cffd8CXLdeg==; From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Richard Sent Subject: Re: [bug#70205] [PATCH] home: services: bash: Move default PS1 prompt to bashrc In-Reply-To: (Richard Sent's message of "Thu, 4 Apr 2024 18:53:27 -0400") References: Date: Mon, 29 Apr 2024 23:53:54 +0200 Message-ID: <87mspbzvgt.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 70164-done Cc: 70205-done@debbugs.gnu.org, paren@disroot.org, Tanguy Le Carrour , Andrew Tropin , 70164-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Richard, Richard Sent skribis: > Reported in . > > * home/services/shells.scm (add-bash-configuration): Move default PS1 pro= mpt > from .bash_profile to .bashrc. > > Change-Id: Ic437458ee362cc4aa803a71c9962af866749f59a Sounds reasonable to me; thanks for the clear explanation in . There was one missing newline before aliases so I made the following change (adding two newlines, for good measure). Applied, thanks! Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index a5b2586dde..ee6b09f17c 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -421,11 +421,11 @@ (define (add-bash-configuration config) ,@(list (file-if-not-empty 'bashrc (if (home-bash-configuration-guix-defaults? config) - (list (plain-file-content %default-bashrc) + (list (plain-file-content %default-bashrc) "\n" ;; The host distro might provide a bad 'PS1' ;; default--e.g., not taking $GUIX_ENVIRONMENT into ;; account. Provide a good default here when asked. - "PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ '" + "PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ '\n" (serialize-field 'aliases)) (list (serialize-field 'aliases)))) (file-if-not-empty 'bash-logout))))) --=-=-=-- ------------=_1714427702-14518-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 3 Apr 2024 15:53:23 +0000 Received: from localhost ([127.0.0.1]:59377 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rs2vT-000739-BG for submit@debbugs.gnu.org; Wed, 03 Apr 2024 11:53:23 -0400 Received: from lists.gnu.org ([2001:470:142::17]:56160) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rs2vN-00071t-LY for submit@debbugs.gnu.org; Wed, 03 Apr 2024 11:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rs2vC-0004zC-Dm for bug-guix@gnu.org; Wed, 03 Apr 2024 11:53:06 -0400 Received: from mail-108-mta57.mxroute.com ([136.175.108.57]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rs2v9-0004FF-VA for bug-guix@gnu.org; Wed, 03 Apr 2024 11:53:06 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta57.mxroute.com (ZoneMTA) with ESMTPSA id 18ea4a9d36f0003bea.001 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 03 Apr 2024 15:52:56 +0000 X-Zone-Loop: 7ce23d45b14c6cd1e0be5663a205947067f132484951 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Wo3jyr2DM5vomixL4DsNZEe+yhZkWMvkIuvrIJEri9w=; b=DbYtT2+bu5e58+LLEzazhv7YlE uWGrFNe8jdXm8tHz+341YalXSmZjGh28/E4mQsIKxNQKTQKXbmuvAZYe1nwD23btYcilEElOW0W4x IuxD7FPMi4NkW9cgsMgv72ag7426DJjOAQVjtPxPUaesUqgBs0ueU7f54nd9lOQsdxmKtR4YLP5Zq wPRxbDUQfzlw2VylRv67bP0AX4cp4JjAcwlnLPbFlNiUO6W9hMEm7Qvk4AWa5I6QIFiESXrLZ+2pj pM7oq2d6x+ayLyzAHoMveqaZ7q4JeHzkfrWufcsBnwJ42mDjK1D3EnPKwfkaf7RSbzMlnz/47iveD EnXoghjw==; From: Richard Sent To: bug-guix@gnu.org Subject: home-bash-service default PS1 overwrites .bashrc PS1 in login shells Date: Wed, 03 Apr 2024 11:52:47 -0400 Message-ID: <87r0fmmoj4.fsf@freakingpenguin.com> MIME-Version: 1.0 Content-Type: text/plain X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.57; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta57.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Hi Guix! A common convention for where to set PS1 is in .bashrc, not .bash_profile [1-3]. Unfortunately home-bash-service doesn't support this convention for login shells. home-bash-service generates a default .bash_profile that follows these steps: 1. Source .profile 2. Source .bashrc 3. Set PS1 if guix-defaults? is truthy This means that any PS1 configuration in .bashrc is overwritten by .bash_profile for login shells specifically. This is visible in a TTY, but also in WSL, which defaults to opening a login shell. PS1 will be Guix's predefined value instead of the value set in .bashrc. Setting guix-defaults? to #f has many side effects, so I don't feel that is a valid solution. A comment in home/serivces/shells.scm suggests setting PS1 via environment-variables since that is appended to the end of .bash_profile. This is fine for simple prompts, but complicated prompts are often split apart into separate bash functions and variables. Either an implicit dependency between .bashrc and .bash_profile is created, or .bash_profile balloons into a mega-file while the conventional wisdom is to keep it as simple as possible. environment-variables also exports PS1, causing it to become an environment variable, not a shell variable. This might cause some odd behavior when subprocesses inherit it. [4] Some possible solutions: 1. Move default PS1 to bashrc, right after serializing %default-bashrc 2. Keep default PS1 in .bash_profile, but before loading .bashrc 3. Add a set-prompt? field to home-bash-configuration Of the 3, I think 1 is the best and plan to submit a patch for it soon. I'm opening the bug in case anyone thinks I missed something. [1] https://unix.stackexchange.com/a/549075 [2] https://superuser.com/a/789465 [3] https://superuser.com/a/789454 [4] https://unix.stackexchange.com/a/44000 -- Take it easy, Richard Sent Making my computer weirder one commit at a time. ------------=_1714427702-14518-1--