zsh-users
 help / color / mirror / code / Atom feed
* param expansion flags
@ 2005-05-06 12:48 Dominic Mitchell
  2005-05-06 16:11 ` Bart Schaefer
  2005-05-06 16:13 ` Haakon Riiser
  0 siblings, 2 replies; 4+ messages in thread
From: Dominic Mitchell @ 2005-05-06 12:48 UTC (permalink / raw)
  To: zsh-users

I'm trying to write a completion file rake (a make like thing for ruby).
You can get a list of targets like this:

    % rake -sT
    rake apidoc                   # Build the apidoc HTML Files
    rake appdoc                   # Build the appdoc HTML Files
    rake clear_logs               # Clears all *.log files in log/

And I'm trying to get that lot into an array parameter that looks like
this:

    targets=(
        'apidoc[Build the apidoc HTML Files]'
        'appdoc[Build the appdoc HTML Files]'
        'clear_logs[Clears all *.log files in log/]'
    )

I've gotten part of the way there, but I can't figure out the rest.  So
far, I've gotten it to split out the lines, remove "rake " from the
front and start putting the initial square bracket in.

    % arr=( ${${${(f)~~"$(rake -sT)"}#rake }/ *# /[} )

Can anyone offer me some advice?

-Dom


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: param expansion flags
  2005-05-06 12:48 param expansion flags Dominic Mitchell
@ 2005-05-06 16:11 ` Bart Schaefer
  2005-05-07 10:16   ` Dominic Mitchell
  2005-05-06 16:13 ` Haakon Riiser
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2005-05-06 16:11 UTC (permalink / raw)
  To: zsh-users

On May 6,  1:48pm, Dominic Mitchell wrote:
} 
} Can anyone offer me some advice?

Do it in several steps and worry later (if ever) about compressing
them down to a single nested parameter expansion.

arr=( ${(f)"$(rake -sT)"} )
arr=( ${arr#rake } )
arr=( ${arr/ *# /\[} )
arr=( ${^arr}\] )


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: param expansion flags
  2005-05-06 12:48 param expansion flags Dominic Mitchell
  2005-05-06 16:11 ` Bart Schaefer
@ 2005-05-06 16:13 ` Haakon Riiser
  1 sibling, 0 replies; 4+ messages in thread
From: Haakon Riiser @ 2005-05-06 16:13 UTC (permalink / raw)
  To: Dominic Mitchell; +Cc: zsh-users

Dominic,

> I've gotten part of the way there, but I can't figure out the rest.  So
> far, I've gotten it to split out the lines, remove "rake " from the
> front and start putting the initial square bracket in.
> 
>     % arr=( ${${${(f)~~"$(rake -sT)"}#rake }/ *# /[} )
> 
> Can anyone offer me some advice?

This seems to work:

  arr=(${^${${${(f)~~"$(rake -sT)"}}#rake }// *# /[}}])

The only difference is that your expression is now placed into
${^...} so that the trailing ] is appended to every line.

-- 
 Haakon


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: param expansion flags
  2005-05-06 16:11 ` Bart Schaefer
@ 2005-05-07 10:16   ` Dominic Mitchell
  0 siblings, 0 replies; 4+ messages in thread
From: Dominic Mitchell @ 2005-05-07 10:16 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-users

On Fri, May 06, 2005 at 04:11:09PM +0000, Bart Schaefer wrote:
> On May 6,  1:48pm, Dominic Mitchell wrote:
> } 
> } Can anyone offer me some advice?
> 
> Do it in several steps and worry later (if ever) about compressing
> them down to a single nested parameter expansion.
> 
> arr=( ${(f)"$(rake -sT)"} )
> arr=( ${arr#rake } )
> arr=( ${arr/ *# /\[} )
> arr=( ${^arr}\] )

Thank you very much -- that's an exceedingly sensible idea.  And I
hadn't used ${^foo} before, so that's something good to learn!

Thanks again,
-Dom


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-05-07 10:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-06 12:48 param expansion flags Dominic Mitchell
2005-05-06 16:11 ` Bart Schaefer
2005-05-07 10:16   ` Dominic Mitchell
2005-05-06 16:13 ` Haakon Riiser

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).