delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-SWARE-Spam-Status: | No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,KHOP_PGP_SIGNED,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS |
X-Spam-Check-By: | sourceware.org |
Message-ID: | <5033AAB8.8010705@redhat.com> |
Date: | Tue, 21 Aug 2012 09:35:20 -0600 |
From: | Eric Blake <eblake AT redhat DOT com> |
User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: /etc/profile |
References: | <loom DOT 20120821T114938-389 AT post DOT gmane DOT org> <50337A02 DOT 8070809 AT redhat DOT com> <loom DOT 20120821T153030-47 AT post DOT gmane DOT org> |
In-Reply-To: | <loom.20120821T153030-47@post.gmane.org> |
OpenPGP: | url=http://people.redhat.com/eblake/eblake.gpg |
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 |
--------------enig2F9C550E0567370E4684C2FF Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 fork= ing a > subshell saves us the restore of LC_ALL... How about this, then (which d= oesn't > fork and handles spaces correctly): >=20 > profile_d () > { > for file in /etc/profile.d/*.$1 ; do > [ -e "${file}" ] && . "${file}" > done > unset file > } >=20 > and then calling it like this: >=20 > LC_ALL=3DC 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=3Dbar; blah() { :; }; foo=3Dbaz blah; echo $foo' baz $ bash -c 'foo=3Dbar; blah() { :; }; foo=3Dbaz blah; echo $foo' bar $ sh -c 'foo=3Dbar; blah() { :; }; foo=3Dbaz blah; echo $foo' baz --=20 Eric Blake eblake AT redhat DOT com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig2F9C550E0567370E4684C2FF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJQM6q4AAoJEKeha0olJ0NqZQ0H/Rl53kRQW0HWykWAoREUUUfO G65mAXm3/jkg4VhKNTJxPcLgDxJsvN1HrTkRF2MJkZynQ0tz9TufWQrflea75U7E MzGKEFUnkC2IxCi96VVGhGuP5xcIxGEQB5YxxjeXspeiJ0eHTGgs19UgNFayzX// hYNYfRfChiqCS0Bv90wZJibBzh/91XWibhh7yGgbWW7SZJB9PPvUB+9LrIa6Qdpi 8PRaMZt/qoW+H/2oidczP3jGbRIghzH2Ssn8wf0isRGLhGnRo2frM78VudGq1TNT ad9K+tV6KOdzIZhUj/zBlo2J4zqPZ3+sdQ3QbyOTUP33c6Dp6laBTKAy6oOzTgM= =Dqjr -----END PGP SIGNATURE----- --------------enig2F9C550E0567370E4684C2FF--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |