From owner-freebsd-questions@FreeBSD.ORG Fri Jan 26 23:02:47 2007 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B2E6C16A400 for ; Fri, 26 Jan 2007 23:02:47 +0000 (UTC) (envelope-from list@museum.rain.com) Received: from ns.umpquanet.com (ns.umpquanet.com [63.105.30.37]) by mx1.freebsd.org (Postfix) with ESMTP id 908A113C487 for ; Fri, 26 Jan 2007 23:02:47 +0000 (UTC) (envelope-from list@museum.rain.com) Received: from ns.umpquanet.com (localhost [127.0.0.1]) by ns.umpquanet.com (8.13.8/8.13.8) with ESMTP id l0QN2gAP095901; Fri, 26 Jan 2007 15:02:43 -0800 (PST) (envelope-from list@museum.rain.com) Received: (from james@localhost) by ns.umpquanet.com (8.13.8/8.13.8/Submit) id l0QN2gWG095900; Fri, 26 Jan 2007 15:02:42 -0800 (PST) (envelope-from list@museum.rain.com) Date: Fri, 26 Jan 2007 15:02:42 -0800 From: James Long To: freebsd-questions@freebsd.org, Bill Campbell Message-ID: <20070126230241.GA93074@ns.umpquanet.com> References: <20070126175122.64D2616A500@hub.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070126175122.64D2616A500@hub.freebsd.org> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: Subject: Re: [OT] Does "~" always point to $HOME? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Jan 2007 23:02:47 -0000 > Message: 24 > Date: Fri, 26 Jan 2007 09:22:44 -0800 > From: Bill Campbell > Subject: Re: [OT] Does "~" always point to $HOME? > To: freebsd-questions@freebsd.org, Bill Campbell > > Message-ID: <20070126172244.GB6575@ayn.mi.celestial.com> > Content-Type: text/plain; charset=us-ascii > > My point isn't whether the FreeBSD /bin/sh expands it, but that not all > systems are FreeBSD, and that one can have problems on other *NIX systems. > > Knowing where there may be differences, and avoiding the assumptions that a > program behaves the same on all systems, can help writing code that's > portable without surprises. This begs the rookie question: What is the portable way to determine an aribtrary user's home directory then, if ~username is not portable across shells? Does one just have to grep and awk /etc/passwd? Is the format of /etc/passwd portable, such that one standard grep/awk sequence will portably return the home directory for user "username"? Regards, Jim P.S. Does this count as the portable way to do this? :) ... USERNAME_HOME="`bash -c "echo ~username"`" cd $USERNAME_HOME ...