Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bad substitution in Parameter Expansion
- X-seq: zsh-users 14874
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Darryl Zurn <darryl.zurn@xxxxxxxxxxxx>
- Subject: Re: Bad substitution in Parameter Expansion
- Date: Wed, 24 Feb 2010 00:10:46 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=RcLMUmXwZmIM1Am0VxyM43TcuvPknpa2uvk+HbIRryo=; b=ggIGv5vQAaqrmBxZvr0OZOJPn73f3xqTwXmtpJJuWnlaNOsgryI+lrJLYLQVs72V1y k1S7r2IloQMweuKf8yUq+OWFwmD8gdaHgNM0/nHSkJrxkZzJvHERxKB2jKEtrvzWTMCR CNb0QEXalWJjFaxkwAqvlQ6H4VYldNOuPZflo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=drqtflbcPhH78UN39R40YyQsE9aUZkr9IkB6avzhkJ7z7ZkDzyXrsLA+as6dz5aCtc 0GBK6PWtNuuvYLQYmgrUYAIX4SZIe5CD7vMLKWDZzaaLAHe5eocHydQ0/S66sTmWI9Ki cHCIWYl0gptJ4AMvjtx6ZR2DFWWmktkC/ehLM=
- In-reply-to: <952282.3121.1266966179597.JavaMail.cyyang@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <952282.3121.1266966179597.JavaMail.cyyang@xxxxxxxxxxxxxx>
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