From owner-freebsd-hackers@FreeBSD.ORG Sat Sep 28 08:12:37 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 0C233E70 for ; Sat, 28 Sep 2013 08:12:37 +0000 (UTC) (envelope-from se@freebsd.org) Received: from nm19-vm0.bullet.mail.ird.yahoo.com (nm19-vm0.bullet.mail.ird.yahoo.com [77.238.189.92]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1112422EE for ; Sat, 28 Sep 2013 08:12:35 +0000 (UTC) Received: from [77.238.189.56] by nm19.bullet.mail.ird.yahoo.com with NNFMP; 28 Sep 2013 08:12:27 -0000 Received: from [46.228.39.71] by tm9.bullet.mail.ird.yahoo.com with NNFMP; 28 Sep 2013 08:12:27 -0000 Received: from [127.0.0.1] by smtp108.mail.ir2.yahoo.com with NNFMP; 28 Sep 2013 08:12:27 -0000 X-Yahoo-Newman-Id: 702683.83249.bm@smtp108.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: mN9iPXwVM1n1_Lug36fVyfvdGjC.Qv6TBXmPvt4DZkg8vzy VX0euHihX3ZM5KeQwUNKJbbFXssBjZUfSKvbdckOKGCNagGMTE5iXCStBkjF HEo5GGFW4f5zXT85FRo5P2yQfGui1BCnX88nrU2KVSC2G7VQR6qAwTW0Ags. ql3viLqzoOeins6Vr5FkL41BHbpaRKvGfDIa.8gK5CeeAQr6Km.RxAxu4VE4 GX3TYbRve9MQgtX.FasSa3rDtg5Zg0wWv7vnubgr2Vj7A7eT2xBjt6VlFL6l ol2QrTF7nJljCHXqqoKTnYMPDxcnUVr48cNYzojIYWUo9OPtd1MU1_2uI45J lw.ZjVoYf0sUKU.80QFLtsFLtL8IB64iaKbhyzHmRFP768y7JKakBC6A9XLj lJijvWO6JHRZYriurnTWkK8D6iz69YW3M6kvMTqHqWBWP3c33fW5vZZ7RGcY jPtClmAoj1I0a15eTxM3fm5EmtUrdj6KAvhx.1d337X27NsNvI_6wO5Kwkxl cmbyxQxK5dgZ6vRYez5BRbCpyeVzgxQ-- X-Yahoo-SMTP: iDf2N9.swBDAhYEh7VHfpgq0lnq. X-Rocket-Received: from [192.168.119.11] (se@84.154.117.89 with ) by smtp108.mail.ir2.yahoo.com with SMTP; 28 Sep 2013 08:12:27 +0000 UTC Message-ID: <52468F62.6010404@freebsd.org> Date: Sat, 28 Sep 2013 10:12:18 +0200 From: Stefan Esser User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Subject: Re: Trying to use /bin/sh References: <1380309632.84323.3.camel@localhost> <20130927221459.GA27990@stack.nl> In-Reply-To: <20130927221459.GA27990@stack.nl> X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Sep 2013 08:12:37 -0000 Am 28.09.2013 00:14, schrieb Jilles Tjoelker: > sh's model of startup files (only login shells use startup files with > fixed names, other interactive shells only use $ENV) assumes that every > session will load /etc/profile and ~/.profile at some point. This > includes graphical sessions. The ENV file typically contains only shell > options, aliases, function definitions and unexported variables but no > environment variables. > > Some graphical environments actually source shell startup files like > ~/.profile when logging in. I remember this from CDE for example. It is > important to have some rule where this should happen to avoid doing it > twice or never in "strange" configurations. As a workaround, I made > ~/.xsession a script interpreted by my login shell and source some > startup files. A problem here is that different login shells have > incompatible startup files. I used to modify Xsession to do the final exec with a forced login shell of the user. This worked for users of all shells. The script identified the shell to use and then used argv0 to start a "login shell" to execute the display manager. A simplified version of my Xsession script is: ------------------------------------------------------------------ #!/bin/sh LIB=/usr/local/lib SH=$SHELL [ -n "$SH" ] || SH="/bin/sh" SHNAME=`basename $SH` echo "exec $LIB/xdm/Xsession.real $*" | \ /usr/local/bin/argv0 $SH -$SHNAME ------------------------------------------------------------------ The argv0 command is part of "sysutils/ucspi-tcp", BTW. This script prepends a "-" to the name of the shell that is started to execute the real "Xsession", which had been renamed to Xession.real. I know that the script could be further simplified by using "modern" variable expansion/substitution commands, but this script was in use some 25 years ago on a variety of Unix systems (SunOS, Ultrix, HP-UX) and I only used the minimal set of Bourne Shell facilities, then. You may want a command to source standard profiles or environment settings before the final exec, in case the users shell does not load them. Regards, STefan