public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* /etc/profile: avoid multiple /usr/bin in PATH
@ 2015-12-06 22:47 Helmut Karlowski
  2015-12-08 21:01 ` Achim Gratz
  2016-09-04 11:32 ` Achim Gratz
  0 siblings, 2 replies; 12+ messages in thread
From: Helmut Karlowski @ 2015-12-06 22:47 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 306 bytes --]

Hello,

I set C:/cygwin/usr/bin in my windows-environment. Now /etc/profile always  
adds /usr/bin to PATH resulting in /usr/bin being twice in my cygwin-PATH.

The attached patch fixes this.

It also sets SHELL if not yet set and avoids a call of hostname.


Maybe the maintainer takes a look.

-Helmut
--

[-- Attachment #2: profile.diff --]
[-- Type: application/octet-stream, Size: 2347 bytes --]

--- defaults/etc/profile	2015-09-26 09:45:02.000000000 +0200
+++ profile	2015-12-06 23:44:38.715400000 +0100
@@ -5,7 +6,7 @@
 # with this software.
 # If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
 
-# base-files version 4.2-4
+# base-files version 4.2-3
 
 # /etc/profile: executed by the command interpreter for login shells.
 
@@ -31,12 +32,27 @@
   # 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}}
+	# add /usr/bin,/usr/local/bin to PATH.
   if [ ${CYGWIN_NOWINPATH-addwinpath} = "addwinpath" ] ; then
-    PATH="/usr/local/bin:/usr/bin${PATH:+:${PATH}}"
+		# avoid multiple path-entries.
+		ifs="$IFS"
+		IFS=:
+		path_localbin=/usr/local/bin
+		path_bin=/usr/bin
+		for p in $PATH; do
+			[ -n "$path_localbin" -a "$p" = "$path_localbin" ] && path_localbin=
+			[ -n "$path_bin" -a "$p" = "$path_bin" ] && path_bin=
+		done
+		: ${ORIGINAL_PATH=${PATH}}
+		if [ -z "$path_bin" -o -z "$path_localbin" ]; then
+			# append :
+			[ -n "$path_localbin" -a -n "$path_bin$PATH" ] && path_localbin=$path_localbin:
+			[ -n "$path_bin" -a -n "$PATH" ] && path_bin=$path_bin:
+			PATH="$path_localbin$path_bin$PATH"
+		fi
+		IFS="$ifs"
   else
-    PATH="/usr/local/bin:/usr/bin"
+		PATH="$path_localbin:$path_bin"
   fi
 
 # see https://cygwin.com/ml/cygwin/2014-05/msg00352.html
@@ -111,6 +127,9 @@
   cd "${HOME}" || echo "WARNING: Failed attempt to cd into ${HOME}!"
 fi
 
+# set default-SHELL
+: ${SHELL:=/bin/sh}
+
 # Shell dependent settings
 profile_d ()
 {
@@ -138,7 +157,7 @@
 if [ ! "x${BASH_VERSION}" = "x"  ]; then
   [ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
 elif [ ! "x${KSH_VERSION}" = "x" ]; then
-  typeset -l HOSTNAME="$(/usr/bin/hostname)"
+	typeset -l HOSTNAME
   [ "${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
   # zsh is in shell compatibility mode here, so we probably shouldn't do this
@@ -151,3 +170,4 @@
 
 # export PROFILEREAD PATH ORIGINAL_PATH MANPATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
 export PROFILEREAD PATH ORIGINAL_PATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL
+

[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

--
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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-09-05 19:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-06 22:47 /etc/profile: avoid multiple /usr/bin in PATH Helmut Karlowski
2015-12-08 21:01 ` Achim Gratz
2015-12-08 21:17   ` Helmut Karlowski
2015-12-08 21:21     ` Achim Gratz
2015-12-08 21:26       ` Helmut Karlowski
2015-12-08 21:31         ` Helmut Karlowski
2015-12-08 21:59           ` Helmut Karlowski
2016-09-04 11:32 ` Achim Gratz
2016-09-05  4:08   ` Doug Henderson
2016-09-05 17:57     ` Achim Gratz
2016-09-05 18:13       ` Vince Rice
2016-09-05 19:07         ` Achim Gratz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).