Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Resolving absolute path of named directory



Hi,

Jesper Nygårds wrote:
> 
> Say I have a string containing a directory name. I know I can use the :a
> modifier to turn the string into the absolute path, but this does not seem
> to work with named directories, and if I read the documentation correctly,
> it's not supposed to. I wonder how I can go about resolving the string if
> it is a named directory.
> 
> Here's an example of what I mean:
> % pwd
> /c/Program/Java
> % ls
> jdk16  jdk17  jre6  jre7
> % mydir="jre6"
> % print ${mydir:a}
> /c/Program/Java/jre6       # Expexted
> % pr=~/projects
> % mydir="~pr"
> % print ${mydir:a}
> /c/Program/Java/~pr        # What I wanted was "/home/jesper/projects"
> 
> So, in the above example, is there a way to make $mydir resolve to the
> absolute path of the named directory ~pr, without using an external program?

I expect what you want is not
  % pr=~/projects
  % mydir="~pr"
but
  % pr=~/projects
  % mydir="$pr"
instead. Or you might want
  % mydir=~/projects
  % print ${mydir:a}


Ciao,
Thomas

-- 
 Thomas Köhler       Email:       jean-luc@xxxxxxxxxxxxxxxxx
     <><             WWW:              http://gott-gehabt.de
                     IRC: tkoehler       Freenode: thkoehler
                     PGP public key available from Homepage!

Attachment: signature.asc
Description: Digital signature



Messages sorted by: Reverse Date, Date, Thread, Author