[OT] Does "~" always point to $HOME?
dghatikachalam at gmail.com
Fri Jan 26 07:33:18 UTC 2007
On 1/26/07, Bill Campbell <freebsd at celestial.com> 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).
> 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.
> I kinda disagree with that because if you want to exploit capabilities of
any given shell we should really stick to those shell
For example , I doubt that we can expect Bourne Shell code to run in CSH
given as such, if it is small piece of code, we just need to stick with its
common capabilities . But then when you are writing fully functional script
such as complete RMAN backup or restore and if you want to automate , you
will need to exploit all capabilities of that give shell for the script to
be fully functional.
More information about the freebsd-questions