[ale] Bash scripting q

JK jknapka at kneuro.net
Thu May 8 21:17:01 EDT 2008


J. D. wrote:
>
>
> On Thu, May 8, 2008 at 6:42 PM, JK <jknapka at kneuro.net 
> <mailto:jknapka at kneuro.net>> wrote:
>
>     J. D. wrote:
>     > Is the desired effect for it to expand to /home/callinguser/user?
>
>     No, the desired effect is for it to expand to the home
>     directory of the user name supplied to the script as
>     arg $1.  So if I say:
>
>
>
> Oh OK that makes sense. If root is running the script though, isn't 
> the tilde
> most always going to return the home directory of the calling user root?

"~user" should expand to "user"'s home dir. A bare ~ expands to the
current user's home.
>
> Using sudo to get the home directory of the target user might be an 
> option.
>
> USERHOME=`sudo -u joe pwd`


I'm actually just using the "eval" solution in my original post. But
it's nice (for some value of "nice") to know that TMTOWTDI.

-- JK

-- 
I do not particularly want to go where the money is -
 it usually does not smell nice there. -- A. Stepanov



More information about the Ale mailing list