From owner-freebsd-questions@freebsd.org Fri Oct 28 15:37:09 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEE71C25564 for ; Fri, 28 Oct 2016 15:37:09 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [IPv6:2001:8b0:151:1:c4ea:bd49:619b:6cb3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 857DB78D for ; Fri, 28 Oct 2016 15:37:09 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from zero-gravitas.local (unknown [85.199.232.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id 144F84384 for ; Fri, 28 Oct 2016 15:37:04 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/144F84384; dkim=none; dkim-atps=neutral Subject: Re: Interesting $0 Problem To: freebsd-questions@freebsd.org References: <516bc76f-f14c-e9a5-a246-2e915a5369ce@qeng-ho.org> <5a4f0424-cdfa-bd44-9de2-b4860d121584@tundraware.com> From: Matthew Seaman Message-ID: Date: Fri, 28 Oct 2016 16:36:54 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <5a4f0424-cdfa-bd44-9de2-b4860d121584@tundraware.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ReLnXHWTLma1RUjELW3cqIecNHdKw8OR3" X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on smtp.infracaninophile.co.uk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Oct 2016 15:37:10 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ReLnXHWTLma1RUjELW3cqIecNHdKw8OR3 Content-Type: multipart/mixed; boundary="xWQt2FIbEuhNPKDOCLEMup8mntPMKR2FX"; protected-headers="v1" From: Matthew Seaman To: freebsd-questions@freebsd.org Message-ID: Subject: Re: Interesting $0 Problem References: <516bc76f-f14c-e9a5-a246-2e915a5369ce@qeng-ho.org> <5a4f0424-cdfa-bd44-9de2-b4860d121584@tundraware.com> In-Reply-To: <5a4f0424-cdfa-bd44-9de2-b4860d121584@tundraware.com> --xWQt2FIbEuhNPKDOCLEMup8mntPMKR2FX Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 2016/10/28 15:40, Tim Daneliuk wrote: > When is it useful for a script to know it's running in a login context = vs. > a child of the login shell? For scripts in general, there probably isn't much utility in distinguishing a login shell from any other shell. What this does do is signal to the shell itself that it needs to run ~/.login or ~/.bash_login or ~/.logout or whatever other (shell specific) initialization or shutdown code is wanted. > Is there another way to determine if your current shell is the login sh= ell? I can't think of one off hand. I thought you might be able to tell if the shell was a process group leader, but it turns out that any interactive shell makes itself into a group leader: lucid-nonsense:~:% ps -o pid,pgid,command PID PGID COMMAND 88932 88932 -tcsh (tcsh) 89001 89001 ps -o pid,pgid,command lucid-nonsense:~:% tcsh lucid-nonsense:~:% ps -o pid,pgid,command PID PGID COMMAND 88932 88932 -tcsh (tcsh) 89003 89003 tcsh 89007 89007 ps -o pid,pgid,command (The test for being a group leader is where PID =3D=3D PGID) Cheers, Matthew --xWQt2FIbEuhNPKDOCLEMup8mntPMKR2FX-- --ReLnXHWTLma1RUjELW3cqIecNHdKw8OR3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQJ8BAEBCgBmBQJYE3CfXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxOUYxNTRFQ0JGMTEyRTUwNTQ0RTNGMzAw MDUxM0YxMEUwQTlFNEU3AAoJEABRPxDgqeTnmHUP/0yBL0sA2yH95a92rfhL0F63 MHW7hYX96nRdQwaaQpLcShdq5NoHaCpO5l+bPGmdMI8/m/1lRlN1huMvPbR6XR/g wdGykWJoJgomYAvmRUqjG85ti301L9Mm6ygdKtdEIFwD2/7fCdRKRJ4yCR2F8eht DvmFaxIbY6muHhj2q2fN2YfnPLnQiITKxTpSFiqUd1BCH382H3cf8WnUlAoDElxN pWk9VXYYRx1bR5K0tVoNFrBf+fLBawK2ATTQvQJ6dBZRbfUKysmbutUQfc4PSQbL eU2guY2JUY2MJnSgxkkZEilgAT2hHDacHFYJvT97b/u3CghYoV5lHRMWShTLT2Di xbrfPHlwSFSR51I9xlTtoX3ifDUUyaHPgQaPhNTlDuU1blKC99suXCeZpbLwzQRt e0KBzaoyuIaStM4fesvHXiuFT/Ewds+B7515f3ND0VurkbBRfFTI7hj5raSPvPEV 3QG0XzWN1BTBztr21ciT/Eth0B83XMeS30LQZMgZXPsRqAUvRg3SBRRVqe9S4+NN HjxXFh24xw4SRJpwL1cCebcHP6tjM8l9MZtOIwH936eCzPlzOjxfRcQy8+Lbk6wm NPOM/g4EqNPumG/l/b/DeqpcVvUbuAN65+kbmp2g1Mw843wl+yuGYPLZ+xrAR2oJ kPC/NH7uGckiKWZAIg+T =LdzX -----END PGP SIGNATURE----- --ReLnXHWTLma1RUjELW3cqIecNHdKw8OR3--