From patchwork Tue Dec 27 21:26:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 45605 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2B20827BBEB; Tue, 27 Dec 2022 21:27:26 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 77F2D27BBE9 for ; Tue, 27 Dec 2022 21:27:23 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAHTT-0001Et-KI; Tue, 27 Dec 2022 16:27:03 -0500 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 1pAHTS-0001ED-DN for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHTS-00040U-3Y for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAHTR-0007t8-VU for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60365] [PATCH 1/4] system, home: Factorize default '.bashrc'. References: <20221227212342.17939-1-ludo@gnu.org> In-Reply-To: <20221227212342.17939-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 27 Dec 2022 21:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60365 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60365@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 60365-submit@debbugs.gnu.org id=B60365.167217639530263 (code B ref 60365); Tue, 27 Dec 2022 21:27:01 +0000 Received: (at 60365) by debbugs.gnu.org; 27 Dec 2022 21:26:35 +0000 Received: from localhost ([127.0.0.1]:56601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHT0-0007rv-77 for submit@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHSy-0007rb-U1 for 60365@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:33 -0500 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 1pAHSt-0003wx-I0; Tue, 27 Dec 2022 16:26:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=yzRijfcOpOS3yxSmBXg9a+6cJjQVJGLS+CDH/FpIX4c=; b=Omon+9Qeph2F4K y3b/Ij70aVFyjVY3YVPVGwG+3nT7slUbz8rf637DNRjhLiiOHeTbbgvvv8OMWNqQB3NbCDyuzF7ue hmvmuExEqHD/L71wGyhORWKtN+krB69bbpRRXYIjOPcVCxajVoMs4wQfQjOn1fpX0ix2D7DP81GRB 02c627uNgrRCGUNxDn6V/hyrSo2z5ppI4fGoRE3Mh0s+TSH1ge5pmO12S/0gd4W2/wi0qijNM/rxV SONWj5YhwaeyuZwD2Ulx3JBtLHTF9PWpJQdgwmUlv7fbL16QUhGFlnAyeb994g/ws70HG2tgUlp82 UieeLTu2KalxXaFgUnCg==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHSt-0007DL-6G; Tue, 27 Dec 2022 16:26:27 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 27 Dec 2022 22:26:15 +0100 Message-Id: <20221227212618.18063-1-ludo@gnu.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/system/shadow.scm (%default-bashrc): New variable. Source /etc/bashrc only if it exists. (default-skeletons): Use it. * gnu/home/services/shells.scm (guix-bashrc): Remove. (add-bash-configuration): Refer to '%default-bashrc' instead. --- gnu/home/services/shells.scm | 41 +++--------------------------------- gnu/system/shadow.scm | 26 +++++++++++++---------- 2 files changed, 18 insertions(+), 49 deletions(-) diff --git a/gnu/home/services/shells.scm b/gnu/home/services/shells.scm index b529c8e798..d7dd579293 100644 --- a/gnu/home/services/shells.scm +++ b/gnu/home/services/shells.scm @@ -19,6 +19,7 @@ (define-module (gnu home services shells) #:use-module (gnu services configuration) + #:autoload (gnu system shadow) (%default-bashrc) #:use-module (gnu home services utils) #:use-module (gnu home services) #:use-module (gnu packages shells) @@ -370,43 +371,6 @@ (define-configuration home-bash-configuration won't be read in some cases (if the shell terminates by exec'ing another process for example).")) -;; TODO: Use value from (gnu system shadow) -(define guix-bashrc - "\ -# Bash initialization for interactive non-login shells and -# for remote shells (info \"(bash) Bash Startup Files\"). - -# Export 'SHELL' to child processes. Programs such as 'screen' -# honor it and otherwise use /bin/sh. -export SHELL - -if [[ $- != *i* ]] -then - # We are being invoked from a non-interactive shell. If this - # is an SSH session (as in \"ssh host command\"), source - # /etc/profile so we get PATH and other essential variables. - [[ -n \"$SSH_CLIENT\" ]] && source /etc/profile - - # Don't do anything else. - return -fi - -# Source the system-wide file. -if [[ -e /etc/bashrc ]]; then - source /etc/bashrc -fi - -# Adjust the prompt depending on whether we're in 'guix environment'. -if [ -n \"$GUIX_ENVIRONMENT\" ] -then - PS1='\\u@\\h \\w [env]\\$ ' -else - PS1='\\u@\\h \\w\\$ ' -fi -alias ls='ls -p --color=auto' -alias ll='ls -l' -alias grep='grep --color=auto'\n") - (define (add-bash-configuration config) (define (filter-fields field) (filter-configuration-fields home-bash-configuration-fields @@ -449,7 +413,8 @@ (define* (file-if-not-empty field #:optional (extra-content #f)) ,@(list (file-if-not-empty 'bashrc (if (home-bash-configuration-guix-defaults? config) - (list (serialize-field 'aliases) guix-bashrc) + (list (serialize-field 'aliases) + (plain-file-content %default-bashrc)) (list (serialize-field 'aliases)))) (file-if-not-empty 'bash-logout))))) diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index 59f0a02c8b..4360a5ebd1 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2013-2020, 2022 Ludovic Courtès ;;; Copyright © 2016 Alex Griffin ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Efraim Flashner @@ -63,7 +63,8 @@ (define-module (gnu system shadow) user-group-id user-group-system?) - #:export (default-skeletons + #:export (%default-bashrc + default-skeletons skeleton-directory %base-groups %base-user-accounts @@ -118,14 +119,8 @@ (define %base-user-accounts (create-home-directory? #f) (system? #t)))) -(define (default-skeletons) - "Return the default skeleton files for /etc/skel. These files are copied by -'useradd' in the home directory of newly created user accounts." - - (let ((profile (plain-file "bash_profile" "\ -# Honor per-interactive-shell startup file -if [ -f ~/.bashrc ]; then . ~/.bashrc; fi\n")) - (bashrc (plain-file "bashrc" "\ +(define %default-bashrc + (plain-file "bashrc" "\ # Bash initialization for interactive non-login shells and # for remote shells (info \"(bash) Bash Startup Files\"). @@ -145,7 +140,7 @@ (define (default-skeletons) fi # Source the system-wide file. -source /etc/bashrc +[ -f /etc/bashrc ] && source /etc/bashrc # Adjust the prompt depending on whether we're in 'guix environment'. if [ -n \"$GUIX_ENVIRONMENT\" ] @@ -157,6 +152,15 @@ (define (default-skeletons) alias ls='ls -p --color=auto' alias ll='ls -l' alias grep='grep --color=auto'\n")) + +(define (default-skeletons) + "Return the default skeleton files for /etc/skel. These files are copied by +'useradd' in the home directory of newly created user accounts." + + (let ((profile (plain-file "bash_profile" "\ +# Honor per-interactive-shell startup file +if [ -f ~/.bashrc ]; then . ~/.bashrc; fi\n")) + (bashrc %default-bashrc) (zprofile (plain-file "zprofile" "\ # Honor system-wide environment variables source /etc/profile\n")) From patchwork Tue Dec 27 21:26:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 45606 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2038B27BBEB; Tue, 27 Dec 2022 21:27:29 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9A00C27BBE9 for ; Tue, 27 Dec 2022 21:27:27 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAHTU-0001FT-Ik; Tue, 27 Dec 2022 16:27:04 -0500 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 1pAHTS-0001EL-OD for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHTS-00040Z-Ff for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAHTS-0007tF-B9 for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60365] [PATCH 2/4] system: Define default 'PS1' in /etc/bashrc rather than ~/.bashrc. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 27 Dec 2022 21:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60365 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60365@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 60365-submit@debbugs.gnu.org id=B60365.167217639930280 (code B ref 60365); Tue, 27 Dec 2022 21:27:02 +0000 Received: (at 60365) by debbugs.gnu.org; 27 Dec 2022 21:26:39 +0000 Received: from localhost ([127.0.0.1]:56605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHT4-0007sI-W2 for submit@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHSz-0007rd-Kg for 60365@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:33 -0500 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 1pAHSu-0003x5-EH; Tue, 27 Dec 2022 16:26:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=T9FJTiQCJAUcBzfAWXqDxlNDP/o4zwVmF0cpNlhwJ8Q=; b=QklAT+fXUPixWfOagNMN yIWGT4EeaC5KYTlmJ4ynJ31FQEhL/3xOKTtWg/j87BWMDCnX2bkl5aQPWRmuuHBcxXXk39CJvdDkz JTxevY5K9AQjf5p+fqyez1at2OGKzMeAo4GlIu8N/r7tyTuQgq969qpNkGwf0XIRnf5ACO+bhqcTA 23J8bc7hQNNbpwhl6WydDBl7Gaf4apJImW23RiXAnVLXUFAKLliaNrWcwjfiNqg1J2PCTcjfnZ8nV l6C+Ie/5XAWb+V01fTDxiQdP49oA/1XS1uDtsa5Hc2el6EL8uk7JgBvaMkNdq9gcEaNmrVswxip0n DW8fBqjqcmahAQ==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHSt-0007DL-Pf; Tue, 27 Dec 2022 16:26:27 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 27 Dec 2022 22:26:16 +0100 Message-Id: <20221227212618.18063-2-ludo@gnu.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221227212618.18063-1-ludo@gnu.org> References: <20221227212618.18063-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Users can override 'PS1' in ~/.bashrc if they wish. Previously, on Guix Home, the "default" 'PS1' would be set in ~/.bashrc when 'home-bash-configuration-guix-defaults?' is true, preventing users from overriding it via the 'environment-variables' field of 'home-bash-extension'. * gnu/system/shadow.scm (%default-bashrc): Remove 'PS1' setting. * gnu/system.scm (operating-system-etc-service): Define PS1 in /etc/bashrc. --- gnu/system.scm | 3 +++ gnu/system/shadow.scm | 7 ------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/gnu/system.scm b/gnu/system.scm index 62c8e0c2b6..d67f9a615b 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -1047,6 +1047,9 @@ (define* (operating-system-etc-service os) (bashrc (plain-file "bashrc" "\ # Bash-specific initialization. +# Provide a default prompt. The user's ~/.bashrc can override it. +PS1='\\u@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ ' + # The 'bash-completion' package. if [ -f /run/current-system/profile/etc/profile.d/bash_completion.sh ] then diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm index 4360a5ebd1..2e87928368 100644 --- a/gnu/system/shadow.scm +++ b/gnu/system/shadow.scm @@ -142,13 +142,6 @@ (define %default-bashrc # Source the system-wide file. [ -f /etc/bashrc ] && source /etc/bashrc -# Adjust the prompt depending on whether we're in 'guix environment'. -if [ -n \"$GUIX_ENVIRONMENT\" ] -then - PS1='\\u@\\h \\w [env]\\$ ' -else - PS1='\\u@\\h \\w\\$ ' -fi alias ls='ls -p --color=auto' alias ll='ls -l' alias grep='grep --color=auto'\n")) From patchwork Tue Dec 27 21:26:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 45607 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 96CAD27BBEB; Tue, 27 Dec 2022 21:27:33 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D290527BBE9 for ; Tue, 27 Dec 2022 21:27:32 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAHTU-0001FY-S0; Tue, 27 Dec 2022 16:27:04 -0500 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 1pAHTT-0001EU-6P for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHTS-00040j-U2 for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAHTS-0007tM-MQ for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60365] [PATCH 3/4] environment: Simplify 'PS1' suggestion on '--check'. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 27 Dec 2022 21:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60365 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60365@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 60365-submit@debbugs.gnu.org id=B60365.167217640030287 (code B ref 60365); Tue, 27 Dec 2022 21:27:02 +0000 Received: (at 60365) by debbugs.gnu.org; 27 Dec 2022 21:26:40 +0000 Received: from localhost ([127.0.0.1]:56607 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHT5-0007sL-D3 for submit@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHT0-0007re-0C for 60365@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:34 -0500 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 1pAHSu-0003xL-Pr; Tue, 27 Dec 2022 16:26:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=8Uc6z+g0WAoQdqJjLWT0uDgMYuY++02kgtRDtvfWg9A=; b=HZbdTSiBN8NDZajBzSCd d5hqywRvA/SGh8kXgL3T29lzWcPbyW2VH7OHF7+HSt2uxSe7i1CW3XKiAr3pyzlVOSKCdFPaT+xas yw4PibDpdiZHG0mTYKrLTAuwfoZeCxqhGTMxhGluRLuJtFyfjYqIRpVjQ/TPirFKwkfDe5uMfHeNa dUj90u0GgHk/NQzwiimKsfvRG0PsV4qMG09Htih9m/DTVLLg7Co7lLVAyA+SXllU6Lfixdn/UpPoH mlpW1KB1h44M5/Mh2xAG+s1/g2UuOZB4rZrehFNeNQDl2MORcQ5YbqfRkHW2FZbkgXSueOAZFaYC4 loFYpbOZ+evLpA==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHSu-0007DL-Cs; Tue, 27 Dec 2022 16:26:28 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 27 Dec 2022 22:26:17 +0100 Message-Id: <20221227212618.18063-3-ludo@gnu.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221227212618.18063-1-ludo@gnu.org> References: <20221227212618.18063-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/environment.scm (validate-child-shell-environment): In 'PS1' suggestion, remove 'export' and avoid 'if'. --- guix/scripts/environment.scm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index ab11b35335..bdbfa03fcf 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -610,10 +610,7 @@ (define-syntax-rule (warn exp ...) @file{~/.bashrc}: @example -if [ -n \"$GUIX_ENVIRONMENT\" ] -then - export PS1=\"\\u@@\\h \\w [env]\\$ \" -fi +PS1='\\u@@\\h \\w${GUIX_ENVIRONMENT:+ [env]}\\$ ' @end example ")))))) From patchwork Tue Dec 27 21:26:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 45608 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A9E2E27BBEB; Tue, 27 Dec 2022 21:27:50 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1752F27BBE9 for ; Tue, 27 Dec 2022 21:27:49 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pAHTW-0001Fc-6y; Tue, 27 Dec 2022 16:27:06 -0500 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 1pAHTT-0001Eq-FO for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHTT-00040q-6D for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pAHTT-0007tU-1X for guix-patches@gnu.org; Tue, 27 Dec 2022 16:27:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#60365] [PATCH 4/4] environment: Avoid false positive on 'PS1' check. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 27 Dec 2022 21:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60365 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 60365@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 60365-submit@debbugs.gnu.org id=B60365.167217640030293 (code B ref 60365); Tue, 27 Dec 2022 21:27:03 +0000 Received: (at 60365) by debbugs.gnu.org; 27 Dec 2022 21:26:40 +0000 Received: from localhost ([127.0.0.1]:56609 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHT5-0007sS-RU for submit@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52368) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pAHT0-0007rg-Jd for 60365@debbugs.gnu.org; Tue, 27 Dec 2022 16:26:34 -0500 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 1pAHSv-0003xU-Cz; Tue, 27 Dec 2022 16:26:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=mFnGOYrRMxmh7l+dvRYR9J5Hwr/OR0s9vi0mN6SICo0=; b=UtZdI3nlYlHVCiBz3c5b WPM2cHU3TBxVz7ofkp/O/1+z/HLG3T9zlc4gnoJCDrcqLQNfXlpge54XNtgcTtiwCRipytW2t56EY 0vZtBR/rT4jkKVBGAfCJ0KdCQfJERA3dYOUxUr3EKOu/AP6wNg0ij0xhk0LXSZBZxVGbx5x/kbTgN OzXyFVuo4EbUk+SYVBd8cJOpN9IVJNtj6k9wl7+TmltL5NuuDxtaTYCmP0cB3lICGmgbdcCL1Jx80 ex06igMTWRdwfpSlN7WiE4iIbKzcsH/PdUAi8lPL+vwRCFLeTIfJt6/ID2o4i2KnV411MSwfYVecK OBtZSt9h6HG4GQ==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pAHSv-0007DL-1C; Tue, 27 Dec 2022 16:26:29 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Tue, 27 Dec 2022 22:26:18 +0100 Message-Id: <20221227212618.18063-4-ludo@gnu.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221227212618.18063-1-ludo@gnu.org> References: <20221227212618.18063-1-ludo@gnu.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/scripts/environment.scm (validate-child-shell-environment): Do not warn when 'PS1' refers to 'GUIX_ENVIRONMENT'. --- guix/scripts/environment.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index bdbfa03fcf..c7fd8fd340 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -601,7 +601,12 @@ (define-syntax-rule (warn exp ...) (match (vhash-assoc "PS1" actual) (#f #f) ((_ . str) - (when (and (getenv "PS1") (string=? str (getenv "PS1"))) + (when (and (getenv "PS1") (string=? str (getenv "PS1")) + + ;; 'PS1' might be conditional on 'GUIX_ENVIRONMENT', as + ;; shown in the hint below. + (not (or (string-contains str "$GUIX_ENVIRONMENT") + (string-contains str "${GUIX_ENVIRONMENT")))) (warning (G_ "'PS1' is the same in sub-shell~%")) (display-hint (G_ "Consider setting a different prompt for environment shells to make them distinguishable.