martin f krafft wrote: > also sprach Bob Proulx <bob@proulx.com> [2004.06.01.0108 +0200]: > > Perhaps. But how? The implementation for different users with bash, > > csh, zsh, ksh, some other weird shell, is probably not impossible but > > I can't think of a way to handle it cleanly. > > exec $(getent passwd `whoami` | cut -d: -f7) --login -c Xsession > > ? Assume /bin/ksh as the login shell for one counter example. That does not produce a valid command for ksh. ksh --login ksh: ksh: --: unknown option Nor for /bin/csh. csh --login Unknown option: `--login' Usage: csh [ -bcdefilmnqstvVxX ] [ argument ... ]. The ksh needs -l to be told it is a login shell. That works for bash and zsh too so looks promising. But csh won't take -l unless it is the only option present. I can't think of a way to pass an option to a shell and have it work for every possible shell. One time in the past I tried using a file of my construction at /etc/X11/Xsession.d/95xfree86-common_userprofile which would load up the user's profile. But at that time the script is /bin/sh. I knew that but we were all running bourne compatible shells. Or so I thought. The first user who put '. /etc/bash_completion' into their $HOME/.profile (read by bash at login) broke things because that is not /bin/sh shell syntax in there. So just noting one type of failure mechanism. The real answer would have to be that the program name starts with a '-' like login shells expect. Of course we can do that[1], but then we need to be able to tell the shell in the shell's command syntax to run the Xsession command. # just for example but not for real echo Xsession | -$(basename $SHELL) Something along those lines seems like the best way to go. I think upstream is the right place to push these types of design decisions. This is not specific to Debian in any way. KDE has this issue on all platforms. > > #!/bin/bash --login > > exec x-session-manager # or startkde or fvwm or whatever > > Thanks. That's what I have been doing. It's just ugly... And poorly documented. Bob [1] Perl comes to mind. Off the top of my head. Untested! #!/usr/bin/perl my $SHELL = $ENV{'SHELL'}; my $SHELL_BASENAME = $SHELL; $SHELL_BASENAME =~ s@.*/@@; exec {$SHELL} "-$SHELL_BASENAME"; -- Bob Proulx <bob@proulx.com> http://www.proulx.com/~bob/ CP-ASEL-IA-Tailwheel-Glider
Attachment:
pgpuS42ihSTja.pgp
Description: PGP signature