[kde-freebsd] Re: patch needed for Xsession
Raphael Kubo da Costa
kubito at gmail.com
Thu Oct 28 05:10:03 CEST 2010
At Wed, 27 Oct 2010 20:51:17 -0600,
M. Warner Losh wrote:
> On 10/27/2010 20:30, Raphael Kubo da Costa wrote:
> > I think I've got a little confused here.
> >
> > In the case we're talking about, /bin/sh is expanding $SHELL to
> > */{csh,tcsh}. If I run /bin/tcsh or /bin/csh by hand here, I cannot
> > run 'export' because it does not seem to be a valid builtin; if I run
> > /bin/sh, I can 'export' and indeed its output is different from
> > 'export -p', while they are identical in bash.
> It is the second /bin/sh that I'm talking about. The first $SHELL is
> indeed /bin/csh or /bin/tcsh, which is why the two ifs work their
> magic. They modify the environment, which is then printed in /bin/sh
> format with the forked /bin/sh export -p (or it would be -p if it were
> quoted).
>
> $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f
> ~/.login) source ~/.login; /bin/sh
> -c export -p >! $xsess_tmp"
>
> The second /bin/sh isn't tcsh, but /bin/sh, and is trying to run export
> -p which is builtin to that shell. However, since Xsession didn't quote
> it, we wind up in the situation that I talked about. sh runs the
> builtin command export with -p as $0. This is exactly what /bin/sh is
> supposed to do.
>
> The reason this works with bash is that 'export' and 'export -p' produce
> the same output. FreeBSD's 'export' produces different output than
> 'export -p'. This conforms to the standards.
>
> That's why the quotes are necessary.
Thanks for the patient explanation :)
I think I've finally understood the situation. As for 'sh runs the
builtin command export with -p as $0', I think you mean that sh runs
the builtin command export, but considers -p an option to itself
(which means it should turn privileged mode on) instead of an option
to the export builtin, right? That's why /bin/sh -c ls -l fails due to
-l not being a valid option to /bin/sh but /bin/sh -c 'ls -l' works as
intended.
More information about the kde-freebsd
mailing list