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

Bill Campbell freebsd at celestial.com
Fri Jan 26 07:03:34 UTC 2007

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).

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.

INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

    Do not meddle in the affairs of dragons,
 for you are crunchy and taste good with ketchup.

More information about the freebsd-questions mailing list