delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/08/25/02:47:46

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.4 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Achim Gratz <Stromeko AT nexgo DOT de>
Subject: Re: /etc/profile
Date: Sat, 25 Aug 2012 08:46:56 +0200
Lines: 188
Message-ID: <87mx1j1na7.fsf@Rainer.invalid>
References: <loom DOT 20120821T114938-389 AT post DOT gmane DOT org> <20120822191002 DOT GA5467 AT pris DOT crapsteak DOT org> <87r4qyloup DOT fsf AT Rainer DOT invalid> <20120822194228 DOT GB5467 AT pris DOT crapsteak DOT org>
Mime-Version: 1.0
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--=-=-=
Content-Type: text/plain

David Sastre Medina writes:
> I'm having this on github now for easier handling.
> Check https://github.com/dsastrem/base-files.git

I've checked the objections raised in this thread and also an older
thread concerning the LC_ALL handling w.r.t. /etc/profile.d and handling
of PS1.  I think these are all valid, patches to do implement them are
attached.  Also, posh didn't run the scripts in /etc/profile.d at all,
which I think is an error even given the limited focus of it.  Also, zsh
runs in sh compatibility mode when it sources /etc/profile, so zsh
extensions shouldn't be used.  I've kept sourcing *.zsh for now since
the only script that comes with the distribution does not use zsh
extensions, but I think it would be cleaner if this wasn't done.  Zsh
might also run in ksh compatibility mode, but I don't know how to check
for that and if it's worth the trouble.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Protect-ORIGINAL_PATH-and-control-behaviour-by-CYGWI.patch
Content-Description: protect ORIGINAL_PATH

From 332ae09f97895197b09793488652a114b1adfa44 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko AT Stromeko DOT DE>
Date: Sat, 25 Aug 2012 08:19:12 +0200
Subject: [PATCH 1/3] Protect ORIGINAL_PATH and control behaviour by
 CYGWIN_NOWINPATH

* etc/defaults/etc/profile: Protect an existing ORIGINAL_PATH
  variable.  Strip windows PATH only from Cygwin path if variable
  CYGWIN_NOWINPATH is set.
---
 etc/defaults/etc/profile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 etc/defaults/etc/profile

diff --git a/etc/defaults/etc/profile b/etc/defaults/etc/profile
old mode 100644
new mode 100755
index b5a803d..4e1f715
--- a/etc/defaults/etc/profile
+++ b/etc/defaults/etc/profile
@@ -29,8 +29,14 @@
 # software to override 'system' software.
 # Modifying these default path settings can be done in different ways.
 # To learn more about startup files, refer to your shell's man page.
-ORIGINAL_PATH="${PATH}"
-PATH="/usr/local/bin:/usr/bin"
+if [ "${ORIGINAL_PATH-null}" = "null" ]; then
+  ${ORIGINAL_PATH}="$PATH"
+fi
+if [ "${CYGWIN_NOWINPATH-null}" = "null" ];then
+  PATH="/usr/local/bin:/usr/bin:${PATH}"
+else
+  PATH="/usr/local/bin:/usr/bin"
+fi
 MANPATH="/usr/local/man:/usr/share/man:/usr/man:${MANPATH}"
 INFOPATH="/usr/local/info:/usr/share/info:/usr/info:${INFOPATH}"
 
-- 
1.7.11.5


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0002-Do-not-set-LC_ALL-unconditionally.patch
Content-Description: Do not set LC_ALL unconditionally

From a39ae961cc31005fa3d831bf66a33aeed7166bf1 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko AT Stromeko DOT DE>
Date: Sat, 25 Aug 2012 08:21:08 +0200
Subject: [PATCH 2/3] Do not set LC_ALL unconditionally

* etc/defaults/etc/profile: Avoid setting LC_ALL if it wasn't set to begin with.
---
 etc/defaults/etc/profile | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/etc/defaults/etc/profile b/etc/defaults/etc/profile
index 4e1f715..ae22836 100755
--- a/etc/defaults/etc/profile
+++ b/etc/defaults/etc/profile
@@ -107,12 +107,19 @@ fi
 # Shell dependent settings
 profile_d ()
 {
-  _LC_SAVE_="{LC_ALL}"
+  _LC_SAVE_="{LC_ALL-null}"
   LC_ALL=C
-  for file in /etc/profile.d/*.$1); do
-    [ -e "${file}" ] && LC_ALL="${_LC_SAVE_}" . "${file}"
-  done
-  LC_ALL="{_LC_SAVE_}"
+  if [ "${_LC_SAVE_}" = "null" ]; then
+    for file in /etc/profile.d/*.$1); do
+      [ -e "${file}" ] && . "${file}"
+    done
+    unset LC_ALL
+  else
+    for file in /etc/profile.d/*.$1); do
+      [ -e "${file}" ] && LC_ALL="${_LC_SAVE_}" . "${file}"
+    done
+    LC_ALL="${_LC_SAVE_}"
+  fi
   unset file
   unset _LC_SAVE_
 }
-- 
1.7.11.5


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0003-Do-not-set-PS1-for-non-interactive-shells.patch
Content-Description: Do not set PS1 for non-interactive shells

From 262da18d10d21e88c3b1a96a689437132271ebc2 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko AT Stromeko DOT DE>
Date: Sat, 25 Aug 2012 08:35:02 +0200
Subject: [PATCH 3/3] Do not set PS1 for non-interactive shells

* etc/defaults/etc/profile: Do not set PS1 for non-interactive shells.
  Zsh is in sh compatibility mode when it sources /etc/profile, so
  don't use zsh extensions.  Posh should also run profile_d.
---
 etc/defaults/etc/profile | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/etc/defaults/etc/profile b/etc/defaults/etc/profile
index ae22836..c55ffca 100755
--- a/etc/defaults/etc/profile
+++ b/etc/defaults/etc/profile
@@ -124,25 +124,20 @@ profile_d ()
   unset _LC_SAVE_
 }
 
+HOSTNAME="$(/usr/bin/hostname)"
+profile_d sh
 if [ ! "x${BASH_VERSION}" = "x"  ]; then
-  HOSTNAME="$(/usr/bin/hostname)"
-  profile_d sh
   [ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
 elif [ ! "x${KSH_VERSION}" = "x" ]; then
   typeset -l HOSTNAME="$(/usr/bin/hostname)"
-  profile_d sh
-  PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
+  [ "${PS1-null}" = "null" ] || PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
 elif [ ! "x${ZSH_VERSION}" = "x" ]; then
-  HOSTNAME="$(/usr/bin/hostname)"
+  # zsh is in shell compatibility mode here, so we probably shouldn't do this
   profile_d zsh
-  PS1='(%n@%m)[%h] %~ %% '
 elif [ ! "x${POSH_VERSION}" = "x" ]; then
-  HOSTNAME="$(/usr/bin/hostname)"
-  PS1="$ "
+  #[ "${PS1-null}" = "null" ] || PS1="$ "
 else 
-  HOSTNAME="$(/usr/bin/hostname)"
-  profile_d sh
-  PS1="$ "
+  #[ "${PS1-null}" = "null" ] || PS1="$ "
 fi
 
 export PATH MANPATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
-- 
1.7.11.5


--=-=-=
Content-Type: text/plain



Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds


--=-=-=
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--=-=-=--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019