From owner-freebsd-current@FreeBSD.ORG Mon Nov 19 19:15:33 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3BAE8A72 for ; Mon, 19 Nov 2012 19:15:33 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id AB9E88FC14 for ; Mon, 19 Nov 2012 19:15:32 +0000 (UTC) Received: by mail-we0-f182.google.com with SMTP id u54so1132785wey.13 for ; Mon, 19 Nov 2012 11:15:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=J1F9YTuoytockzF75zYtJ/V+HkZf1MsWXSgMNiCn4Os=; b=nEGjLc7I00IqSsCoWM+oUAA8PX9eJhaVZRvj/wJcFrnVCJDtc1sOAF8XManiKTMaXY hh/moxyNVksru3mf0FMtcXnxlLM0p30i8YSjsVKtRAjSMuROt/aiIpK8ceh/0wPRiKMi VW/Gq+rB20GmFqwVmTliUMuSpoTt4jiUgjn/h+T2oi898MhCiURUvWmVN2sneLmCM2XV acMWARbTcUglcpiJSydtReQxUl7UTHQ/xSBLTRE8tPO0iNIoQbqc6b5/uCrs40nLfPqz SAwhV1uel+JCPY6Gf2eZeSPs0GjeQawyYO6m0AC5PMfiCK3o/g3ElGthbIa4sz9Ow2n1 lssQ== Received: by 10.216.228.28 with SMTP id e28mr3108532weq.48.1353352531307; Mon, 19 Nov 2012 11:15:31 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPS id dd4sm10594308wib.2.2012.11.19.11.15.29 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Nov 2012 11:15:30 -0800 (PST) Date: Mon, 19 Nov 2012 20:15:22 +0100 From: Mateusz Guzik To: Eitan Adler Subject: Re: prompt w/ uid 0 for cshrc Message-ID: <20121119191521.GA22292@dft-labs.eu> Mail-Followup-To: Mateusz Guzik , Eitan Adler , freebsd-current Current References: <20121118234426.GA16628@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-current Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Nov 2012 19:15:33 -0000 On Mon, Nov 19, 2012 at 10:45:35AM -0500, Eitan Adler wrote: > On 18 November 2012 18:44, Mateusz Guzik wrote: > > Just take user name from id -nu. > > While that does provide the $user value I want, id is in /usr/bin/ > which may not be mounted. > Is there a builtin which provides similar functionality? > Valid point, but should not happen a lot when unprivileged accounts are involved, so I suggest the following (pseudo-sh-code): if [ -x /usr/bin/id ]; then up=$(id -nu); else if [ $uid = 0 ]; then up="root"; else up="($uid)" fi -- Mateusz Guzik