This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: /etc/profile


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: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]