Date: Fri, 26 Jan 2007 15:02:42 -0800 From: James Long <list@museum.rain.com> To: freebsd-questions@freebsd.org, Bill Campbell <freebsd@celestial.com> Subject: Re: [OT] Does "~" always point to $HOME? Message-ID: <20070126230241.GA93074@ns.umpquanet.com> In-Reply-To: <20070126175122.64D2616A500@hub.freebsd.org> References: <20070126175122.64D2616A500@hub.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> Message: 24 > Date: Fri, 26 Jan 2007 09:22:44 -0800 > From: Bill Campbell <freebsd@celestial.com> > Subject: Re: [OT] Does "~" always point to $HOME? > To: freebsd-questions@freebsd.org, Bill Campbell > <freebsd@celestial.com> > 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 ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070126230241.GA93074>