Re: [OT] Does ~ always point to $HOME?
Bill Campbell wrote: On Fri, Jan 26, 2007, James Long wrote: Message: 24 Date: Fri, 26 Jan 2007 09:22:44 -0800 From: Bill Campbell [EMAIL PROTECTED] Subject: Re: [OT] Does ~ always point to $HOME? To: freebsd-questions@freebsd.org, Bill Campbell [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] 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? Probably the most portable way to do this would be to use awk. A simple script, homedir, might look like this: #!/bin/sh # getting the backwhacks correct is sometimes ``interesting'' homedir=`awk -F: /^$1:/{print \\$6} /etc/passwd` [ -z $homedir ] { echo 'empty home for ' $1 21 exit 1 } echo $homedir exit 0 That does assume that all the user information is stored within the local /etc/passwd -- if you're using NIS or LDAP or anything like that, then you need a method that calls getpwnam(3) for you. TIMTOWTDI: pw user show -n $username | cut -d: -f 9 (But pw(8) is FreeBSD specific) perl -le print +(getpwnam($username))[7]; su $username -c 'echo $HOME' (But only if the script is running with root privileges) Of course, none of these methods are guaranteed to work in all circumstances. In which case, you might as well choose to program in a language or for an interpreter that is readily available on the systems you are writing the code for and that provides the functionality you need. On FreeBSD that probably comes down to using ~username with /bin/sh (with liberal comments warning of uportable assumptions, of course) -- which should work unmodified with any of the *BSDs or MacOS X. If you program the rest of the script carefully it should also work with bash under Linux (and others) or even (I think) ksh on Solaris. Portability is hard. Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW signature.asc Description: OpenPGP digital signature
Re: [OT] Does ~ always point to $HOME?
On Sat, Jan 27, 2007, Matthew Seaman wrote: Bill Campbell wrote: ... Probably the most portable way to do this would be to use awk. A simple script, homedir, might look like this: #!/bin/sh # getting the backwhacks correct is sometimes ``interesting'' homedir=`awk -F: /^$1:/{print \\$6} /etc/passwd` [ -z $homedir ] { echo 'empty home for ' $1 21 exit 1 } echo $homedir exit 0 That does assume that all the user information is stored within the local /etc/passwd -- if you're using NIS or LDAP or anything like that, then you need a method that calls getpwnam(3) for you. A one-liner that should take care of these is: python -c import os.path; print os.path.expanduser('~$username') (This doesn't work with python-1.5.1 on an ancient Linux system as os.path didn't appear until later). Bill -- INTERNET: [EMAIL PROTECTED] 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 ``A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.'' Robert Heinlein ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Campbell wrote: On Sat, Jan 27, 2007, Matthew Seaman wrote: Bill Campbell wrote: ... Probably the most portable way to do this would be to use awk. A simple script, homedir, might look like this: #!/bin/sh # getting the backwhacks correct is sometimes ``interesting'' homedir=`awk -F: /^$1:/{print \\$6} /etc/passwd` [ -z $homedir ] { echo 'empty home for ' $1 21 exit 1 } echo $homedir exit 0 That does assume that all the user information is stored within the local /etc/passwd -- if you're using NIS or LDAP or anything like that, then you need a method that calls getpwnam(3) for you. A one-liner that should take care of these is: python -c import os.path; print os.path.expanduser('~$username') (This doesn't work with python-1.5.1 on an ancient Linux system as os.path didn't appear until later). Bill Not all systems contain python though (and many don't), so $HOME is still a better bet. Thanks though for the idea, - -Garrett -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.1 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFu8SGEnKyINQw/HARAvGpAJ4hbwv6YiF0rootWd/QTlQ1ZvweWgCgqwZ9 JCm3yiKBP2cX9dXwvIiYOz4= =Cpfv -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Matthew Seaman wrote: Bill Campbell wrote: On Fri, Jan 26, 2007, James Long wrote: Message: 24 Date: Fri, 26 Jan 2007 09:22:44 -0800 From: Bill Campbell [EMAIL PROTECTED] Subject: Re: [OT] Does ~ always point to $HOME? To: freebsd-questions@freebsd.org, Bill Campbell [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] 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? Probably the most portable way to do this would be to use awk. A simple script, homedir, might look like this: #!/bin/sh # getting the backwhacks correct is sometimes ``interesting'' homedir=`awk -F: /^$1:/{print \\$6} /etc/passwd` [ -z $homedir ] { echo 'empty home for ' $1 21 exit 1 } echo $homedir exit 0 That does assume that all the user information is stored within the local /etc/passwd -- if you're using NIS or LDAP or anything like that, then you need a method that calls getpwnam(3) for you. TIMTOWTDI: pw user show -n $username | cut -d: -f 9 (But pw(8) is FreeBSD specific) perl -le print +(getpwnam($username))[7]; su $username -c 'echo $HOME' (But only if the script is running with root privileges) Of course, none of these methods are guaranteed to work in all circumstances. In which case, you might as well choose to program in a language or for an interpreter that is readily available on the systems you are writing the code for and that provides the functionality you need. On FreeBSD that probably comes down to using ~username with /bin/sh (with liberal comments warning of uportable assumptions, of course) -- which should work unmodified with any of the *BSDs or MacOS X. If you program the rest of the script carefully it should also work with bash under Linux (and others) or even (I think) ksh on Solaris. Portability is hard. Cheers, Matthew Yes, but I don't know of any engineering firms right off hand that run the BSDs. Quite a few engineering groups run solaris or linux, just because the machines are donated or the number of support folks who are familiar with the operating platform and can maintain the systems is higher. - -Garrett -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.1 (FreeBSD) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFu8V9EnKyINQw/HARAtDZAKCtj1ZXIb3llJF9uyUwoVKtlINwcACfQguh TyuMDnbUd/Jiw3nHVvyO2bQ= =v2tL -END PGP SIGNATURE- ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
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? % [EMAIL PROTECTED] uname -spr % FreeBSD 6.2-STABLE i386 % [EMAIL PROTECTED] printenv SHELL % /bin/sh % [EMAIL PROTECTED] cd test % [EMAIL PROTECTED] pwd % /home/karol/test % [EMAIL PROTECTED] cd ~ % [EMAIL PROTECTED] pwd % /home/karol % [EMAIL PROTECTED] cd ~kadu % [EMAIL PROTECTED] 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 signature.asc Description: OpenPGP digital signature
Re: [OT] Does ~ always point to $HOME?
On Fri, 26 Jan 2007 15:21:14 +0100 Karol Kwiatkowski [EMAIL PROTECTED] wrote: 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? FreeBSD /bin/sh is actually an ash, which roughly translates into a POSIX shell with a few additions that do not break compatibility. At least that is how I understood it. Joerg -- | /\ ASCII ribbon | GnuPG Key ID | e86d b753 3deb e749 6c3a | | \ / campaign against |0xbbcaad24 | 5706 1f7d 6cfd bbca ad24 | | XHTML in email |.the next sentence is true. | | / \ and news | .the previous sentence was a lie.| -- | /\ ASCII ribbon | GnuPG Key ID | e86d b753 3deb e749 6c3a | | \ / campaign against |0xbbcaad24 | 5706 1f7d 6cfd bbca ad24 | | XHTML in email |.the next sentence is true. | | / \ and news | .the previous sentence was a lie.| ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On Fri, Jan 26, 2007, Joerg Pernfuss wrote: On Fri, 26 Jan 2007 15:21:14 +0100 Karol Kwiatkowski [EMAIL PROTECTED] wrote: 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? FreeBSD /bin/sh is actually an ash, which roughly translates into a POSIX shell with a few additions that do not break compatibility. At least that is how I understood it. 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. One of the major reasons I have been using GNU utilities on Unix systems for twenty-plus years, built with the ``g'' prefix, is to have a common set of programs which behave the same regardless of platform. Stallman would probably say I ran GNU/Xenix, GNU/SunOS, GNU/OpenServer, etc. Bill -- INTERNET: [EMAIL PROTECTED] 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 ``Most people, sometime in their lives, stumble across truth. Most jump up, brush themselves off, and hurry on about their business as if nothing had happened.'' - Sir Winston Churchill ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On Fri, 26 Jan 2007, Joerg Pernfuss wrote: On Fri, 26 Jan 2007 15:21:14 +0100 Karol Kwiatkowski [EMAIL PROTECTED] wrote: 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? FreeBSD /bin/sh is actually an ash, which roughly translates into a POSIX shell with a few additions that do not break compatibility. At least that is how I understood it. Joerg -- | /\ ASCII ribbon | GnuPG Key ID | e86d b753 3deb e749 6c3a | | \ / campaign against |0xbbcaad24 | 5706 1f7d 6cfd bbca ad24 | | XHTML in email |.the next sentence is true. | | / \ and news | .the previous sentence was a lie.| -- | /\ ASCII ribbon | GnuPG Key ID | e86d b753 3deb e749 6c3a | | \ / campaign against |0xbbcaad24 | 5706 1f7d 6cfd bbca ad24 | | XHTML in email |.the next sentence is true. | | / \ and news | .the previous sentence was a lie.| Unfortunately the target system (now) for the documentation is suse Linux, and I don't have any control over what the company chooses for its Unix OS in the future. So to reduce rewriting the documentation in the future I thought it'd be better to seek out the common denominator in Unix shells. Besides, if people are smart enough (and most people are here), they can translate $HOME to ~ :). -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
Message: 24 Date: Fri, 26 Jan 2007 09:22:44 -0800 From: Bill Campbell [EMAIL PROTECTED] Subject: Re: [OT] Does ~ always point to $HOME? To: freebsd-questions@freebsd.org, Bill Campbell [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] 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 ... ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On Fri, Jan 26, 2007, James Long wrote: Message: 24 Date: Fri, 26 Jan 2007 09:22:44 -0800 From: Bill Campbell [EMAIL PROTECTED] Subject: Re: [OT] Does ~ always point to $HOME? To: freebsd-questions@freebsd.org, Bill Campbell [EMAIL PROTECTED] Message-ID: [EMAIL PROTECTED] 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? Probably the most portable way to do this would be to use awk. A simple script, homedir, might look like this: #!/bin/sh # getting the backwhacks correct is sometimes ``interesting'' homedir=`awk -F: /^$1:/{print \\$6} /etc/passwd` [ -z $homedir ] { echo 'empty home for ' $1 21 exit 1 } echo $homedir exit 0 Bill -- INTERNET: [EMAIL PROTECTED] 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 ``Fix reason firmly in her seat and call to her tribunal every fact, every opinion. Question with boldness even the existence of a God; because, if there is one, he must more approve of the homage of reason, than that of blindfolded fear.'' --Thomas Jefferson ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
[OT] Does ~ always point to $HOME?
Hello again, I'm revising some documentation that has examples of running Unix commands and I want to make sure that my steps are correct, such that I can substitute the tilde character ('~') for $HOME. The only issue I can see with this is an improper configuration with sudo (ran into some problems with $HOME in the past using sudo on Gentoo), but I'm pretty sure that sudo's setup on the machine cluster properly. TIA, -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On Thu, Jan 25, 2007, [EMAIL PROTECTED] wrote: Hello again, I'm revising some documentation that has examples of running Unix commands and I want to make sure that my steps are correct, such that I can substitute the tilde character ('~') for $HOME. The only issue I can see with this is an improper configuration with sudo (ran into some problems with $HOME in the past using sudo on Gentoo), but I'm pretty sure that sudo's setup on the machine cluster properly. That's true on most relatively modern shells, but not on pure Bourne Shell, /bin/sh. As for ``sudo'', ``sudo -'' invokes the login environment while a plain ``sudo'' doesn't. Bill -- INTERNET: [EMAIL PROTECTED] 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 ``If we got one-tenth of what was promised to us in these acceptance speeches there wouldn't be any inducement to go to heaven.'' Will Rogers ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On Thu, 25 Jan 2007, Bill Campbell wrote: On Thu, Jan 25, 2007, [EMAIL PROTECTED] wrote: Hello again, I'm revising some documentation that has examples of running Unix commands and I want to make sure that my steps are correct, such that I can substitute the tilde character ('~') for $HOME. The only issue I can see with this is an improper configuration with sudo (ran into some problems with $HOME in the past using sudo on Gentoo), but I'm pretty sure that sudo's setup on the machine cluster properly. That's true on most relatively modern shells, but not on pure Bourne Shell, /bin/sh. As for ``sudo'', ``sudo -'' invokes the login environment while a plain ``sudo'' doesn't. Bill -- INTERNET: [EMAIL PROTECTED] 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 ``If we got one-tenth of what was promised to us in these acceptance speeches there wouldn't be any inducement to go to heaven.'' Will Rogers Ok, I'll stick with home then. Thanks! -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
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 Regards Dak On 1/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello again, I'm revising some documentation that has examples of running Unix commands and I want to make sure that my steps are correct, such that I can substitute the tilde character ('~') for $HOME. The only issue I can see with this is an improper configuration with sudo (ran into some problems with $HOME in the past using sudo on Gentoo), but I'm pretty sure that sudo's setup on the machine cluster properly. TIA, -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On 1/26/07, Dak Ghatikachalam [EMAIL PROTECTED] 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 Regards Dak On 1/25/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello again, I'm revising some documentation that has examples of running Unix commands and I want to make sure that my steps are correct, such that I can substitute the tilde character ('~') for $HOME. The only issue I can see with this is an improper configuration with sudo (ran into some problems with $HOME in the past using sudo on Gentoo), but I'm pretty sure that sudo's setup on the machine cluster properly. TIA, -Garrett ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] Oops sorry for top posting , I sent that mail accidentally at the rush of the blood. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
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. Bill -- INTERNET: [EMAIL PROTECTED] 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. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [OT] Does ~ always point to $HOME?
On 1/26/07, Bill Campbell [EMAIL PROTECTED] 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. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]