This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "which" command does not expand "~" in path

On Sun, 26 Sep 2004, Sven Köhler wrote:

> > > Instead, the shell usually substitutes ~ or ~user.
> > > Look at this the output of these commands:
> > >     echo ~
> > >     echo "~"
> >
> > This is probably common knowledge, but I learned last night that sh never
> > expands ~.  Under sh, the two lines above yield the same output, simply ~.
> I can confirm that for cygwin.
> The "common knowledge" may be, because the most Linux-systems have sh linked
> to bash. Cygwin seems to have a separate "sh" installed.

As do most non-Linux systems.

> But is there any command that give's me the home for a given username?

bash -c "echo ~username"


Or you could write one using the getpwnam() call (better yet, the
reentrant versions, getpwnam_r()), and submit it to, say, cygutils (since
sh-utils is no longer being actively developed).
      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw
Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]