/etc/profile
Eric Blake
eblake@redhat.com
Tue Aug 21 16:50:00 GMT 2012
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20120821/a6360c4c/attachment.sig>
More information about the Cygwin
mailing list