[OT] Does "~" always point to $HOME?

Karol Kwiatkowski karol.kwiat at gmail.com
Fri Jan 26 14:46:01 UTC 2007


Bill Campbell wrote:
> On Fri, Jan 26, 2007, Dak Ghatikachalam wrote:
>> I write shells script extensively , I have noticed
>>
>> ~      -> gets a subsitution for $HOME
>> ~userid   - >gets you the $HOME for that user
>>
>> meaning if  you have  have logged in as root and  if you want to run some
>> script on oracle home even though you logged in as root  you can simplly
>>
>> ~oracle/runme.sh  -- > will run the runme.sh in Oracle home directory
> 
> While that's true for most shells, bash, csh, tcsh, etc., it
> doesn't work on true Bourne /bin/sh shells (e.g. SCO OpenServer
> 5.0.6a and earlier and probably others with Bell Labs ancestors).

Not sure what I'm missing, is FreeBSD's /bin/sh shell not "true" Bourne
Shell? Was it extended in some way from traditional one?

% karol at blackacidevil$ uname -spr
% FreeBSD 6.2-STABLE i386
% karol at blackacidevil$ printenv SHELL
% /bin/sh
% karol at blackacidevil$ cd test
% karol at blackacidevil$ pwd
% /home/karol/test
% karol at blackacidevil$ cd ~
% karol at blackacidevil$ pwd
% /home/karol
% karol at blackacidevil$ cd ~kadu
% karol at blackacidevil$ pwd
% /home/kadu


> It's a Good Idea(tm) when writing scripts that may be used on
> many systems to program defensively, for the lowest common
> denominator to avoid pitfalls like this.
>
> Bill

Agreed.

Karol

-- 
Karol Kwiatkowski   <karol.kwiat at gmail dot com>
OpenPGP 0x06E09309

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20070126/7698ef67/signature.pgp


More information about the freebsd-questions mailing list