public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* /etc/profile
@ 2012-08-21 15:03 Achim Gratz
  2012-08-21 15:35 ` /etc/profile Eric Blake
  2012-08-22 19:42 ` /etc/profile David Sastre Medina
  0 siblings, 2 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-21 15:03 UTC (permalink / raw)
  To: cygwin

I'm removing the Windows PATH in my startup scripts since there's nothing in
there that I think should be accessible from Cygwin.

For (t)csh this is easy enough to do with dropping a script into /etc/profile.d
that gets executed first, but there's no such provision for sh and the ilk since
PATH is set up already before it get there.  Now, unless profile gets changed I
can still cut off "/usr/local/bin:/usr/bin:" with a profile.d script, but I
think it might be preferrable that the Windows path gets recorded into
ORIGINAL_PATH or some similar name at the beginning of profile.  It would then
be a simple matter to later add the Windows path where appropriate, but I don't
think the default path should have it at all.

Also, there are two things in profile that may admit slight improvement (a place
where LC_COLLATE is specified just for one command and better guarding against a
missing or non-cdable /etc/skel).

Patch:
--- /etc/defaults/etc/profile   2012-02-27 22:03:33.000000000 +0100
+++ /etc/profile        2012-08-21 12:12:42.617969800 +0200
@@ -29,7 +29,8 @@
 # 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.
-PATH="/usr/local/bin:/usr/bin:${PATH}"
+ORIGINAL_PATH=$PATH
+PATH="/usr/local/bin:/usr/bin"
 MANPATH="/usr/local/man:/usr/share/man:/usr/man:${MANPATH}"
 INFOPATH="/usr/local/info:/usr/share/info:/usr/info:${INFOPATH}"

@@ -75,14 +76,17 @@
     echo
     echo "They will never be overwritten nor automatically updated."
     echo
-    cd /etc/skel || echo "WARNING: Failed attempt to cd into /etc/skel!"
-    /usr/bin/find . -type f | while read f; do
-      fDest=${f#.}
-      if [ ! -e "${HOME}${fDest}" -a ! -L "${HOME}${fDest}" ]; then
-        /usr/bin/install -D -p -v "${f}" "${HOME}/${fDest}"
-      fi
-    done
-    unset fDest
+    if ! cd /etc/skel ; then
+      echo "WARNING: Failed attempt to cd into /etc/skel!"
+    else
+      /usr/bin/find . -type f | while read f; do
+       fDest=${f#.}
+       if [ ! -e "${HOME}${fDest}" -a ! -L "${HOME}${fDest}" ]; then
+          /usr/bin/install -D -p -v "${f}" "${HOME}/${fDest}"
+       fi
+      done
+      unset fDest
+    fi
   else
     echo "${HOME} could not be created."
     { [ -d "${TEMP}" ] && HOME="${TEMP}"; } ||
@@ -103,7 +107,7 @@
 # Shell dependent settings
 profile_d ()
 {
-  for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
+  for file in $(LC_COLLATE=C echo /etc/profile.d/*.$1); do
     [ -e "${file}" ] && . "${file}"
   done
   unset file



Regards,
Achim.




--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-21 15:03 /etc/profile Achim Gratz
@ 2012-08-21 15:35 ` Eric Blake
  2012-08-21 15:57   ` /etc/profile Achim Gratz
  2012-08-22 19:42 ` /etc/profile David Sastre Medina
  1 sibling, 1 reply; 27+ messages in thread
From: Eric Blake @ 2012-08-21 15:35 UTC (permalink / raw)
  To: cygwin

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

On 08/21/2012 04:16 AM, Achim Gratz wrote:
> I'm removing the Windows PATH in my startup scripts since there's nothing in
> there that I think should be accessible from Cygwin.

Unfortunately, at least your windows system dll directory has to be on
PATH, or cygwin1.dll will fail to load, so blindly removing ALL windows
paths from PATH is wrong.

> Also, there are two things in profile that may admit slight improvement (a place
> where LC_COLLATE is specified just for one command and better guarding against a
> missing or non-cdable /etc/skel).

A missing /etc/skel is a sign of mis-installation, but extra guards
won't hurt, I guess.  But you are wrong about the LC_COLLATE command
having no effect.  Remember, the shell is required to expand globbing
prior to executing a command, but that LC_COLLATE affects how globbing
is performed.  Therefore, you MUST separate the assignment from
LC_COLLATE from the globbing, if the globbing is to be affected (for
that matter, if LC_ALL is set, then it overrides LC_COLLATE, so it may
be better to patch this particular usage to set LC_ALL instead of
LC_COLLATE).

> @@ -103,7 +107,7 @@
>  # Shell dependent settings
>  profile_d ()
>  {
> -  for file in $(export LC_COLLATE=C; echo /etc/profile.d/*.$1); do
> +  for file in $(LC_COLLATE=C echo /etc/profile.d/*.$1); do

Given my above arguments, if this changes at all, it should change to:
for file in $(LC_ALL=C; echo /etc/profile.d/*.$1); do

but that is not safe for files containing whitespace.  If you want
safety, then we should avoid the $() and use globbing directly, although
it gets much longer with something like this:

saved_LC_ALL=$LC_ALL
set_LC_ALL=${LC_ALL+set}
LC_ALL=C
for file in /etc/profile.d/*.$1; do
  if test $set_LC_ALL
    LC_ALL=$saved_LC_ALL
  else
    unset LC_ALL
  fi
  # original loop body
done
if test $set_LC_ALL
  LC_ALL=$saved_LC_ALL
else
  unset LC_ALL
fi
unset saved_LC_ALL set_LC_ALL

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

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

* Re: /etc/profile
  2012-08-21 15:35 ` /etc/profile Eric Blake
@ 2012-08-21 15:57   ` Achim Gratz
  2012-08-21 16:11     ` /etc/profile James Johnston
                       ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-21 15:57 UTC (permalink / raw)
  To: cygwin


Eric Blake <eblake <at> redhat.com> writes:
> Unfortunately, at least your windows system dll directory has to be on
> PATH, or cygwin1.dll will fail to load, so blindly removing ALL windows
> paths from PATH is wrong.

At that point cygwin1.dll is already loaded and so far I haven't seen anything
not working due to that change.  But yes, I didn't think of that, so I'm curious
why it seems to work as nicely as it does.

> A missing /etc/skel is a sign of mis-installation, but extra guards
> won't hurt, I guess.

Specifically, that fail would induce the copy of files from whatever the current
directory is into whatever HOME is set to.  I guess that could potentially cause
a lot of damage...

> But you are wrong about the LC_COLLATE command
> having no effect.

I didn't say it doesn't have an effect.

>  Remember, the shell is required to expand globbing
> prior to executing a command, but that LC_COLLATE affects how globbing
> is performed.

Yes, I missed that globbing was performed before the change in locale treatment
went active.

>  Therefore, you MUST separate the assignment from
> LC_COLLATE from the globbing, if the globbing is to be affected (for
> that matter, if LC_ALL is set, then it overrides LC_COLLATE, so it may
> be better to patch this particular usage to set LC_ALL instead of
> LC_COLLATE).

Yes, that seems like a good idea, even though I can't imagine why LC_ALL would
already be set at that point... OK, it gets imported when I set it from Windows
System Properties.  I'll have to think about unsetting these unconditionally,
then.

> but that is not safe for files containing whitespace.  If you want
> safety, then we should avoid the $() and use globbing directly, although
> it gets much longer with something like this:

That saves us a fork, so it may even be a net win, on the other hand forking a
subshell saves us the restore of LC_ALL...  How about this, then (which doesn't
fork and handles spaces correctly):

profile_d ()
{
  for file in /etc/profile.d/*.$1 ; do
    [ -e "${file}" ] && . "${file}"
  done
  unset file
}

and then calling it like this:

  LC_ALL=C profile_d *.sh

The "unset file" could also go if the call included a "file= ",
I'd think.


Thanks for having a look.


Regards,
Achim.


--
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] 27+ messages in thread

* RE: /etc/profile
  2012-08-21 15:57   ` /etc/profile Achim Gratz
@ 2012-08-21 16:11     ` James Johnston
  2012-08-21 16:50     ` /etc/profile Eric Blake
  2012-08-21 17:24     ` /etc/profile Earnie Boyd
  2 siblings, 0 replies; 27+ messages in thread
From: James Johnston @ 2012-08-21 16:11 UTC (permalink / raw)
  To: cygwin

> -----Original Message-----
> Sent: Tuesday, August 21, 2012 14:39
> Subject: Re: /etc/profile
> 
> 
> Eric Blake <eblake <at> redhat.com> writes:
> > Unfortunately, at least your windows system dll directory has to be on
> > PATH, or cygwin1.dll will fail to load, so blindly removing ALL
> > windows paths from PATH is wrong.
> 
> At that point cygwin1.dll is already loaded and so far I haven't seen
anything
> not working due to that change.  But yes, I didn't think of that, so I'm
curious
> why it seems to work as nicely as it does.
> 

Read section "Search order for desktop applications" at "Dynamic-Link
Library Search Order" at
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).as
px

Bottom line, you don't need system32 in the path for DLL loading to work.  I
seem to recall that some earlier versions of Windows actually did not
include system32 in the PATH by default.


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-21 15:57   ` /etc/profile Achim Gratz
  2012-08-21 16:11     ` /etc/profile James Johnston
@ 2012-08-21 16:50     ` Eric Blake
  2012-08-21 17:21       ` /etc/profile Achim Gratz
  2012-08-21 17:24     ` /etc/profile Earnie Boyd
  2 siblings, 1 reply; 27+ messages in thread
From: Eric Blake @ 2012-08-21 16:50 UTC (permalink / raw)
  To: cygwin

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

On 08/21/2012 08:38 AM, Achim Gratz wrote:
> That saves us a fork, so it may even be a net win, on the other hand forking a
> subshell saves us the restore of LC_ALL...  How about this, then (which doesn't
> fork and handles spaces correctly):
> 
> profile_d ()
> {
>   for file in /etc/profile.d/*.$1 ; do
>     [ -e "${file}" ] && . "${file}"
>   done
>   unset file
> }
> 
> and then calling it like this:
> 
>   LC_ALL=C profile_d *.sh

Sorry, POSIX requires that to leave LC_ALL set after the function call,
which is not what you want (bash behaves differently according to
whether it was started as bash or sh).

$ ksh -c 'foo=bar; blah() { :; }; foo=baz blah; echo $foo'
baz
$ bash -c 'foo=bar; blah() { :; }; foo=baz blah; echo $foo'
bar
$ sh -c 'foo=bar; blah() { :; }; foo=baz blah; echo $foo'
baz

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

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

* Re: /etc/profile
  2012-08-21 16:50     ` /etc/profile Eric Blake
@ 2012-08-21 17:21       ` Achim Gratz
  2012-08-21 19:27         ` /etc/profile Eric Blake
  0 siblings, 1 reply; 27+ messages in thread
From: Achim Gratz @ 2012-08-21 17:21 UTC (permalink / raw)
  To: cygwin

Eric Blake writes:
> Sorry, POSIX requires that to leave LC_ALL set after the function
> call,

Interesting.  Where is that specified?

> which is not what you want (bash behaves differently according to
> whether it was started as bash or sh).

OK, it wasn't the same as the original invocation anyway since now the
scripts would be called with LC_ALL=C set (which might be exactly what
you wanted, but still...) — so perhaps:

profile_d ()
{
  _LC_SAVE_="$LC_ALL"
  LC_ALL=C
  for file in /etc/profile.d/*.$1 ; do
    [ -e "${file}" ] && LC_ALL="$_LC_SAVE_" . "${file}"
  done
  LC_ALL="$_LC_SAVE_"
  unset file
  unset _LC_SAVE_
}

That leaves the original function calls the same as well.


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

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


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-21 15:57   ` /etc/profile Achim Gratz
  2012-08-21 16:11     ` /etc/profile James Johnston
  2012-08-21 16:50     ` /etc/profile Eric Blake
@ 2012-08-21 17:24     ` Earnie Boyd
  2 siblings, 0 replies; 27+ messages in thread
From: Earnie Boyd @ 2012-08-21 17:24 UTC (permalink / raw)
  To: cygwin

On Tue, Aug 21, 2012 at 10:38 AM, Achim Gratz wrote:
>
> Eric Blake <eblake <at> redhat.com> writes:
>> Unfortunately, at least your windows system dll directory has to be on
>> PATH, or cygwin1.dll will fail to load, so blindly removing ALL windows
>> paths from PATH is wrong.
>
> At that point cygwin1.dll is already loaded and so far I haven't seen anything
> not working due to that change.  But yes, I didn't think of that, so I'm curious
> why it seems to work as nicely as it does.

Right, I remove windows PATHS from my PATH after starting with my
.profile and .bash_profile files.  Besides, the Windows library search
order will search for known DLL in known directories automagicly.

-- 
Earnie
-- https://sites.google.com/site/earnieboyd

--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-21 17:21       ` /etc/profile Achim Gratz
@ 2012-08-21 19:27         ` Eric Blake
  2012-08-21 20:48           ` /etc/profile Achim Gratz
  0 siblings, 1 reply; 27+ messages in thread
From: Eric Blake @ 2012-08-21 19:27 UTC (permalink / raw)
  To: cygwin

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

On 08/21/2012 09:56 AM, Achim Gratz wrote:
> Eric Blake writes:
>> Sorry, POSIX requires that to leave LC_ALL set after the function
>> call,
> 
> Interesting.  Where is that specified?

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05

When a function is executed, it shall have the syntax-error and
variable-assignment properties described for special built-in utilities
in the enumerated list at the beginning of Special Built-In Utilities.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14

Variable assignments specified with special built-in utilities remain in
effect after the built-in completes; this shall not be the case with a
regular built-in or other utility.

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 620 bytes --]

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

* Re: /etc/profile
  2012-08-21 19:27         ` /etc/profile Eric Blake
@ 2012-08-21 20:48           ` Achim Gratz
  0 siblings, 0 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-21 20:48 UTC (permalink / raw)
  To: cygwin

Eric Blake writes:
>> Interesting.  Where is that specified?
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_05
>
> When a function is executed, it shall have the syntax-error and
> variable-assignment properties described for special built-in utilities
> in the enumerated list at the beginning of Special Built-In Utilities.
>
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14
>
> Variable assignments specified with special built-in utilities remain in
> effect after the built-in completes; this shall not be the case with a
> regular built-in or other utility.

Thank you.


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


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-21 15:03 /etc/profile Achim Gratz
  2012-08-21 15:35 ` /etc/profile Eric Blake
@ 2012-08-22 19:42 ` David Sastre Medina
  2012-08-22 20:10   ` /etc/profile Achim Gratz
  2012-08-22 20:36   ` /etc/profile Daniel Colascione
  1 sibling, 2 replies; 27+ messages in thread
From: David Sastre Medina @ 2012-08-22 19:42 UTC (permalink / raw)
  To: cygwin

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

On Tue, Aug 21, 2012 at 10:16:28AM +0000, Achim Gratz wrote:
> I'm removing the Windows PATH in my startup scripts since there's nothing in
> there that I think should be accessible from Cygwin.
> For (t)csh this is easy enough to do with dropping a script into /etc/profile.d
> that gets executed first, but there's no such provision for sh and the ilk since
> PATH is set up already before it get there.  Now, unless profile gets changed I
> can still cut off "/usr/local/bin:/usr/bin:" with a profile.d script, but I
> think it might be preferrable that the Windows path gets recorded into
> ORIGINAL_PATH or some similar name at the beginning of profile.  It would then
> be a simple matter to later add the Windows path where appropriate, but I don't
> think the default path should have it at all.
> Also, there are two things in profile that may admit slight improvement (a place
> where LC_COLLATE is specified just for one command and better guarding against a
> missing or non-cdable /etc/skel).

All three changes will be available in the next release (profile_d
modification taken from your last version in this thread).

Thanks.

-- 
Primary key fingerprint: AD8F BDC0 5A2C FD5F A179  60E7 F79B AB04 5299 EC56

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: /etc/profile
  2012-08-22 19:42 ` /etc/profile David Sastre Medina
@ 2012-08-22 20:10   ` Achim Gratz
  2012-08-22 20:15     ` /etc/profile David Sastre Medina
  2012-08-22 20:36   ` /etc/profile Daniel Colascione
  1 sibling, 1 reply; 27+ messages in thread
From: Achim Gratz @ 2012-08-22 20:10 UTC (permalink / raw)
  To: cygwin

David Sastre Medina writes:
> All three changes will be available in the next release (profile_d
> modification taken from your last version in this thread).
>
> Thanks.

Thank you.  If you'd rather have a complete patch, let me know and I'll
post it or send it to you via email, as you prefer.


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

SD adaptations for KORG EX-800 and Poly-800MkII V0.9:
http://Synth.Stromeko.net/Downloads.html#KorgSDada


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:10   ` /etc/profile Achim Gratz
@ 2012-08-22 20:15     ` David Sastre Medina
  2012-08-22 20:50       ` /etc/profile Achim Gratz
  2012-08-25 15:45       ` /etc/profile Achim Gratz
  0 siblings, 2 replies; 27+ messages in thread
From: David Sastre Medina @ 2012-08-22 20:15 UTC (permalink / raw)
  To: cygwin

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

On Wed, Aug 22, 2012 at 09:15:58PM +0200, Achim Gratz wrote:
> If you'd rather have a complete patch, let me know and I'll
> post it or send it to you via email, as you prefer.

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

-- 
Primary key fingerprint: AD8F BDC0 5A2C FD5F A179  60E7 F79B AB04 5299 EC56

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: /etc/profile
  2012-08-22 19:42 ` /etc/profile David Sastre Medina
  2012-08-22 20:10   ` /etc/profile Achim Gratz
@ 2012-08-22 20:36   ` Daniel Colascione
  2012-08-22 20:51     ` /etc/profile Achim Gratz
  2012-08-22 22:08     ` /etc/profile David Sastre Medina
  1 sibling, 2 replies; 27+ messages in thread
From: Daniel Colascione @ 2012-08-22 20:36 UTC (permalink / raw)
  To: cygwin

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

On 8/22/12 12:10 PM, David Sastre Medina wrote:
> On Tue, Aug 21, 2012 at 10:16:28AM +0000, Achim Gratz wrote:
>> I'm removing the Windows PATH in my startup scripts since there's nothing in
>> there that I think should be accessible from Cygwin.
>> For (t)csh this is easy enough to do with dropping a script into /etc/profile.d
>> that gets executed first, but there's no such provision for sh and the ilk since
>> PATH is set up already before it get there.  Now, unless profile gets changed I
>> can still cut off "/usr/local/bin:/usr/bin:" with a profile.d script, but I
>> think it might be preferrable that the Windows path gets recorded into
>> ORIGINAL_PATH or some similar name at the beginning of profile.  It would then
>> be a simple matter to later add the Windows path where appropriate, but I don't
>> think the default path should have it at all.
>> Also, there are two things in profile that may admit slight improvement (a place
>> where LC_COLLATE is specified just for one command and better guarding against a
>> missing or non-cdable /etc/skel).
> 
> All three changes will be available in the next release (profile_d
> modification taken from your last version in this thread).

Are you sure that's actually a good idea? I don't agree with this logic:

>> I'm removing the Windows PATH in my startup scripts since there's
nothing in
>> there that I think should be accessible from Cygwin.

People execute Windows programs using Cygwin all the time. With this
change, basic things like "cmd" and "notepad" will fail to work.
Working with Windows programs is the *point* of Cygwin. I really don't
think this change should go into the default startup scripts.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 235 bytes --]

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

* Re: /etc/profile
  2012-08-22 20:15     ` /etc/profile David Sastre Medina
@ 2012-08-22 20:50       ` Achim Gratz
  2012-08-25 15:45       ` /etc/profile Achim Gratz
  1 sibling, 0 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-22 20:50 UTC (permalink / raw)
  To: cygwin

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

Ah, nice.  Everythings OK, thank you.


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

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:36   ` /etc/profile Daniel Colascione
@ 2012-08-22 20:51     ` Achim Gratz
  2012-08-22 20:55       ` /etc/profile Andrey Repin
  2012-08-22 20:55       ` /etc/profile Christopher Faylor
  2012-08-22 22:08     ` /etc/profile David Sastre Medina
  1 sibling, 2 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-22 20:51 UTC (permalink / raw)
  To: cygwin

Daniel Colascione writes:
> People execute Windows programs using Cygwin all the time. With this
> change, basic things like "cmd" and "notepad" will fail to work.
> Working with Windows programs is the *point* of Cygwin. I really don't
> think this change should go into the default startup scripts.

The change is about giving users a choice.  You can now drop a script
into profile.d that just does:

PATH="${PATH}:${ORIGINAL_PATH}"

and have exactly the same behaviour as you have now (and David might
consider installing that by default).  Or you don't and are not bothered
by the useless stuff corporate IT adds to Windows PATH without even
checking that it works correctly on Windows, let alone together with
Cygwin.


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

Wavetables for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldUserWavetables


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:51     ` /etc/profile Achim Gratz
@ 2012-08-22 20:55       ` Andrey Repin
  2012-08-22 22:52         ` /etc/profile Achim Gratz
  2012-08-22 20:55       ` /etc/profile Christopher Faylor
  1 sibling, 1 reply; 27+ messages in thread
From: Andrey Repin @ 2012-08-22 20:55 UTC (permalink / raw)
  To: Achim Gratz, cygwin

Greetings, Achim Gratz!

>> People execute Windows programs using Cygwin all the time. With this
>> change, basic things like "cmd" and "notepad" will fail to work.
>> Working with Windows programs is the *point* of Cygwin. I really don't
>> think this change should go into the default startup scripts.

> The change is about giving users a choice.  You can now drop a script
> into profile.d that just does:

> PATH="${PATH}:${ORIGINAL_PATH}"

The point it, I don't want this.
My $PATH is set in Windows, and I do not modify it in startup scripts.


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 23.08.2012, <00:44>

Sorry for my terrible english...


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:51     ` /etc/profile Achim Gratz
  2012-08-22 20:55       ` /etc/profile Andrey Repin
@ 2012-08-22 20:55       ` Christopher Faylor
  2012-08-22 21:18         ` /etc/profile Achim Gratz
  1 sibling, 1 reply; 27+ messages in thread
From: Christopher Faylor @ 2012-08-22 20:55 UTC (permalink / raw)
  To: cygwin

On Wed, Aug 22, 2012 at 10:24:24PM +0200, Achim Gratz wrote:
>Daniel Colascione writes:
>> People execute Windows programs using Cygwin all the time. With this
>> change, basic things like "cmd" and "notepad" will fail to work.
>> Working with Windows programs is the *point* of Cygwin. I really don't
>> think this change should go into the default startup scripts.
>
>The change is about giving users a choice.  You can now drop a script
>into profile.d that just does:
>
>PATH="${PATH}:${ORIGINAL_PATH}"
>
>and have exactly the same behaviour as you have now (and David might
>consider installing that by default).  Or you don't and are not bothered
>by the useless stuff corporate IT adds to Windows PATH without even
>checking that it works correctly on Windows, let alone together with
>Cygwin.

If we are changing a longstanding behavior then I agree with Daniel that
this is a bad idea.  You're just asking for people to be confused.

If you want to make it easy to remove the Windows PATH then I guess I
can see why that would be useful but it seems like anyone for whom this
would be an issue would know how to do this anyway so I don't see why we
have to go to great lengths to accommodate anyone who wants this.

cgf

--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:55       ` /etc/profile Christopher Faylor
@ 2012-08-22 21:18         ` Achim Gratz
  2012-08-23  6:35           ` /etc/profile Andrew DeFaria
  0 siblings, 1 reply; 27+ messages in thread
From: Achim Gratz @ 2012-08-22 21:18 UTC (permalink / raw)
  To: cygwin

Christopher Faylor writes:
> If we are changing a longstanding behavior then I agree with Daniel that
> this is a bad idea.  You're just asking for people to be confused.

Again, I'm not arguing for changing the default.  In fact, as long as
ORIGINAL_PATH stays available it might even still be added to PATH in
/etc/profile, although I still think it is cleaner to install
/etc/profile.d/00_add_windows_path.sh in base-files with the contents
I've shown.  If it's already been added then removing it with just the
means of a POSIX shell is a bit involved, but even that would be a
possibility.

> If you want to make it easy to remove the Windows PATH then I guess I
> can see why that would be useful but it seems like anyone for whom this
> would be an issue would know how to do this anyway so I don't see why we
> have to go to great lengths to accommodate anyone who wants this.

The issue is that to effect that customization I have to change a file
that is not supposed to be changed (since that prevents any updates from
getting to it automatically).


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

SD adaptation for Waldorf microQ V2.22R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:36   ` /etc/profile Daniel Colascione
  2012-08-22 20:51     ` /etc/profile Achim Gratz
@ 2012-08-22 22:08     ` David Sastre Medina
  2012-08-23  5:54       ` /etc/profile Christopher Faylor
  1 sibling, 1 reply; 27+ messages in thread
From: David Sastre Medina @ 2012-08-22 22:08 UTC (permalink / raw)
  To: cygwin

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

On Wed, Aug 22, 2012 at 01:13:37PM -0700, Daniel Colascione wrote:
> On 8/22/12 12:10 PM, David Sastre Medina wrote:
> > On Tue, Aug 21, 2012 at 10:16:28AM +0000, Achim Gratz wrote:
> >> I'm removing the Windows PATH in my startup scripts since there's nothing in
> >> there that I think should be accessible from Cygwin.
> > 
> > All three changes will be available in the next release (profile_d
> > modification taken from your last version in this thread).
> 
> Are you sure that's actually a good idea? I don't agree with this logic:
> People execute Windows programs using Cygwin all the time. With this
> change, basic things like "cmd" and "notepad" will fail to work.
> Working with Windows programs is the *point* of Cygwin. I really don't
> think this change should go into the default startup scripts.

I for one never start windows programs from within a shell, with the
exception of firefox, and for that I registered an entry in the
alternatives system (x-www-browser), however, I take your advice and
I'll give this a second thought, and also would like to hear from
others' opnion wrt to this.
Obviously, ORIGINAL_PATH (as proposed in Achim's patch) would
still hold the native Windows' PATH, so it'd be very easy to include a
(commented?) line using it, so it would be easy to switch it:

#PATH="/usr/local/bin:/usr/bin:${ORIGINAL_PATH}"

-- 
Primary key fingerprint: AD8F BDC0 5A2C FD5F A179  60E7 F79B AB04 5299 EC56

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: /etc/profile
  2012-08-22 20:55       ` /etc/profile Andrey Repin
@ 2012-08-22 22:52         ` Achim Gratz
  0 siblings, 0 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-22 22:52 UTC (permalink / raw)
  To: cygwin

Andrey Repin writes:
> Greetings, Achim Gratz!
>
>>> People execute Windows programs using Cygwin all the time. With this
>>> change, basic things like "cmd" and "notepad" will fail to work.
>>> Working with Windows programs is the *point* of Cygwin. I really don't
>>> think this change should go into the default startup scripts.
>
>> The change is about giving users a choice.  You can now drop a script
>> into profile.d that just does:
>
>> PATH="${PATH}:${ORIGINAL_PATH}"
>
> The point it, I don't want this.

You do realise that this is exactly what is done today, just at a
different place, do you?

> My $PATH is set in Windows, and I do not modify it in startup scripts.

Yes you do, in /etc/profile - check it yourself.


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

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


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 22:08     ` /etc/profile David Sastre Medina
@ 2012-08-23  5:54       ` Christopher Faylor
  2012-08-23  6:19         ` /etc/profile David Sastre Medina
  2012-08-23 10:03         ` /etc/profile Achim Gratz
  0 siblings, 2 replies; 27+ messages in thread
From: Christopher Faylor @ 2012-08-23  5:54 UTC (permalink / raw)
  To: cygwin

On Wed, Aug 22, 2012 at 10:55:08PM +0200, David Sastre Medina wrote:
>On Wed, Aug 22, 2012 at 01:13:37PM -0700, Daniel Colascione wrote:
>> On 8/22/12 12:10 PM, David Sastre Medina wrote:
>> > On Tue, Aug 21, 2012 at 10:16:28AM +0000, Achim Gratz wrote:
>> >> I'm removing the Windows PATH in my startup scripts since there's nothing in
>> >> there that I think should be accessible from Cygwin.
>> > 
>> > All three changes will be available in the next release (profile_d
>> > modification taken from your last version in this thread).
>> 
>> Are you sure that's actually a good idea? I don't agree with this logic:
>> People execute Windows programs using Cygwin all the time. With this
>> change, basic things like "cmd" and "notepad" will fail to work.
>> Working with Windows programs is the *point* of Cygwin. I really don't
>> think this change should go into the default startup scripts.
>
>I for one never start windows programs from within a shell, with the
>exception of firefox, and for that I registered an entry in the
>alternatives system (x-www-browser), however, I take your advice and
>I'll give this a second thought, and also would like to hear from
>others' opnion wrt to this.
>Obviously, ORIGINAL_PATH (as proposed in Achim's patch) would
>still hold the native Windows' PATH, so it'd be very easy to include a
>(commented?) line using it, so it would be easy to switch it:
>
>#PATH="/usr/local/bin:/usr/bin:${ORIGINAL_PATH}"

I'll just reiterate what Daniel said again: We can't make things like
cmd or notepad stop working.  That would be a disaster.

I wasn't really following the discussion, and don't really want to check
stuff out in git to see what's going on, but if the proposed change just
makes it possible for purists to remove the Windows PATH from the Cygwin
one however that's great.  Otherwise, removing the Windows path entirely
really won't please very many people.

cgf

--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-23  5:54       ` /etc/profile Christopher Faylor
@ 2012-08-23  6:19         ` David Sastre Medina
  2012-08-23 10:03         ` /etc/profile Achim Gratz
  1 sibling, 0 replies; 27+ messages in thread
From: David Sastre Medina @ 2012-08-23  6:19 UTC (permalink / raw)
  To: cygwin

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

On Wed, Aug 22, 2012 at 05:18:31PM -0400, Christopher Faylor wrote:
> I'll just reiterate what Daniel said again: We can't make things like
> cmd or notepad stop working.  That would be a disaster.
> I wasn't really following the discussion, and don't really want to check
> stuff out in git to see what's going on, but if the proposed change just
> makes it possible for purists to remove the Windows PATH from the Cygwin
> one however that's great.  Otherwise, removing the Windows path entirely
> really won't please very many people.

ACK. I'll keep PATH untouched and see if there are other ways to offer this
functionality as an option.

-- 
Primary key fingerprint: AD8F BDC0 5A2C FD5F A179  60E7 F79B AB04 5299 EC56

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 230 bytes --]

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

* Re: /etc/profile
  2012-08-22 21:18         ` /etc/profile Achim Gratz
@ 2012-08-23  6:35           ` Andrew DeFaria
  0 siblings, 0 replies; 27+ messages in thread
From: Andrew DeFaria @ 2012-08-23  6:35 UTC (permalink / raw)
  To: cygwin

On 8/22/2012 1:50 PM, Achim Gratz wrote:
> The issue is that to effect that customization I have to change a file that is not supposed to be changed (since that prevents any updates from getting to it automatically).
I've long since (circa 1994 or so) had a script called set_path that I 
can source to set my path from scratch. My ~/.bashrc calls it. I can add 
on different directories as required from my various clients. 
Directories only get added to the path if they exist.

Now why can't you do similar? It would not be "changing a file that is 
not supposed to be changes" rather it would be changing files that you 
own and that should be changed.

It's your environment - take control of it!
-- 
Andrew DeFaria <http://defaria.com>
Artificial Intelligence usually beats real stupidity.


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-23  5:54       ` /etc/profile Christopher Faylor
  2012-08-23  6:19         ` /etc/profile David Sastre Medina
@ 2012-08-23 10:03         ` Achim Gratz
  2012-08-23 10:29           ` /etc/profile L Anderson
  1 sibling, 1 reply; 27+ messages in thread
From: Achim Gratz @ 2012-08-23 10:03 UTC (permalink / raw)
  To: cygwin

Christopher Faylor writes:
> I'll just reiterate what Daniel said again: We can't make things like
> cmd or notepad stop working.  That would be a disaster.

Yes, and nobody proposed otherwise.

> I wasn't really following the discussion, and don't really want to check
> stuff out in git to see what's going on, but if the proposed change just
> makes it possible for purists to remove the Windows PATH from the Cygwin
> one however that's great.

OK, here it is again in a nutshell, it has two parts:

1. instead of adding the windows PATH in /etc/profile (which doesn't
need it _at all_), just record it there into ORIGINAL_PATH.

2. Add a script to /etc/profile.d which concatenates the Cygwin and the
windows path to provide the same net result as todays /etc/profile.


I hope this avoids more TLDR;


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

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-23 10:03         ` /etc/profile Achim Gratz
@ 2012-08-23 10:29           ` L Anderson
  0 siblings, 0 replies; 27+ messages in thread
From: L Anderson @ 2012-08-23 10:29 UTC (permalink / raw)
  To: cygwin

Achim Gratz wrote:
> Christopher Faylor writes:
>> I'll just reiterate what Daniel said again: We can't make things like
>> cmd or notepad stop working.  That would be a disaster.
>
> Yes, and nobody proposed otherwise.
>
>> I wasn't really following the discussion, and don't really want to check
>> stuff out in git to see what's going on, but if the proposed change just
>> makes it possible for purists to remove the Windows PATH from the Cygwin
>> one however that's great.
>
> OK, here it is again in a nutshell, it has two parts:
>
> 1. instead of adding the windows PATH in /etc/profile (which doesn't
> need it _at all_), just record it there into ORIGINAL_PATH.

But I already have my own ORIGINAL_PATH set for my cygwin environment 
for my own use

No joy!!

LA


--
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] 27+ messages in thread

* Re: /etc/profile
  2012-08-22 20:15     ` /etc/profile David Sastre Medina
  2012-08-22 20:50       ` /etc/profile Achim Gratz
@ 2012-08-25 15:45       ` Achim Gratz
  2012-08-25 21:26         ` /etc/profile Achim Gratz
  1 sibling, 1 reply; 27+ messages in thread
From: Achim Gratz @ 2012-08-25 15:45 UTC (permalink / raw)
  To: cygwin

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

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: protect ORIGINAL_PATH --]
[-- Type: text/x-patch, Size: 1343 bytes --]

From 332ae09f97895197b09793488652a114b1adfa44 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: Do not set LC_ALL unconditionally --]
[-- Type: text/x-patch, Size: 1167 bytes --]

From a39ae961cc31005fa3d831bf66a33aeed7166bf1 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Do not set PS1 for non-interactive shells --]
[-- Type: text/x-patch, Size: 1801 bytes --]

From 262da18d10d21e88c3b1a96a689437132271ebc2 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.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


[-- Attachment #5: Type: text/plain, Size: 200 bytes --]



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


[-- Attachment #6: 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] 27+ messages in thread

* Re: /etc/profile
  2012-08-25 15:45       ` /etc/profile Achim Gratz
@ 2012-08-25 21:26         ` Achim Gratz
  0 siblings, 0 replies; 27+ messages in thread
From: Achim Gratz @ 2012-08-25 21:26 UTC (permalink / raw)
  To: cygwin

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

Achim Gratz writes:
[...]
Hit send too soon... here's the patch set again without the typos.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Protect-ORIGINAL_PATH-and-control-behaviour-by-CYGWI.patch --]
[-- Type: text/x-patch, Size: 1342 bytes --]

From 8a930eb8adc4d9364ea0d6c8f63be448c539b448 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.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..5458446
--- 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Do-not-set-LC_ALL-unconditionally.patch --]
[-- Type: text/x-patch, Size: 1166 bytes --]

From c3a3b56e8402f373507585bbeee5509e0df22412 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.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 5458446..c3d9c47 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0003-Do-not-set-PS1-for-non-interactive-shells.patch --]
[-- Type: text/x-patch, Size: 1809 bytes --]

From f03f4ab0b47312959dd9d57a520af3f4a4c50011 Mon Sep 17 00:00:00 2001
From: Achim Gratz <Stromeko@Stromeko.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 c3d9c47..1e63c32 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


[-- Attachment #5: Type: text/plain, Size: 187 bytes --]



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

Samples for the Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#BlofeldSamplesExtra


[-- Attachment #6: 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] 27+ messages in thread

end of thread, other threads:[~2012-08-25  7:26 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-21 15:03 /etc/profile Achim Gratz
2012-08-21 15:35 ` /etc/profile Eric Blake
2012-08-21 15:57   ` /etc/profile Achim Gratz
2012-08-21 16:11     ` /etc/profile James Johnston
2012-08-21 16:50     ` /etc/profile Eric Blake
2012-08-21 17:21       ` /etc/profile Achim Gratz
2012-08-21 19:27         ` /etc/profile Eric Blake
2012-08-21 20:48           ` /etc/profile Achim Gratz
2012-08-21 17:24     ` /etc/profile Earnie Boyd
2012-08-22 19:42 ` /etc/profile David Sastre Medina
2012-08-22 20:10   ` /etc/profile Achim Gratz
2012-08-22 20:15     ` /etc/profile David Sastre Medina
2012-08-22 20:50       ` /etc/profile Achim Gratz
2012-08-25 15:45       ` /etc/profile Achim Gratz
2012-08-25 21:26         ` /etc/profile Achim Gratz
2012-08-22 20:36   ` /etc/profile Daniel Colascione
2012-08-22 20:51     ` /etc/profile Achim Gratz
2012-08-22 20:55       ` /etc/profile Andrey Repin
2012-08-22 22:52         ` /etc/profile Achim Gratz
2012-08-22 20:55       ` /etc/profile Christopher Faylor
2012-08-22 21:18         ` /etc/profile Achim Gratz
2012-08-23  6:35           ` /etc/profile Andrew DeFaria
2012-08-22 22:08     ` /etc/profile David Sastre Medina
2012-08-23  5:54       ` /etc/profile Christopher Faylor
2012-08-23  6:19         ` /etc/profile David Sastre Medina
2012-08-23 10:03         ` /etc/profile Achim Gratz
2012-08-23 10:29           ` /etc/profile L Anderson

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