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

Re: Bad substitution in Parameter Expansion



On 24 February 2010 00:02, Darryl Zurn <darryl.zurn@xxxxxxxxxxxx> wrote:
> Iâm using zsh 4.3.6 (i386-apple-darwin8.11.1) on Mac OS X 10.5.8
>
> I am trying to write a little function to transmogrify a copied filepath into something I can cd to, quickly. I have the path which looks something like this:
>
>  Document Control:Volume2:530XX:53043:B1&B2:53043B1&2_4.dwg
>
> And I want it to look like this for a proper cd command:
>
>  cd /Volumes/Document\ Control/Volume2/530XX/53043/B1&B2/
>
> Note that I need to add â/Volumes/â to the front, I need to replace all colons with
> forward-slashes,

> then I need to escape all spaces with â\ â

No, you don't. You escape things when you input them, this text is
already in a variable.

> Hereâs what happens when I put it into a simple function:
> (16:51:%)  dt () {
> (function)    if [[ -z $1 ]]
> (function if)         then
> (function then)               print Need arguments
> (function then)       else
                                cd /Volumes/${${1//:/\/}:h}

-- 
Mikael Magnusson



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