On Tue, Jun 16, 2009 at 19:55, Philip Ganchev <[email protected]>wrote:
> I don't understand the intention here, nor the desired output. See:
> http://fishshell.org/user_doc/index.html
> http://fishshell.org/user_doc/commands.html#for
> http://fishshell.org/user_doc/index.html#expand
>
> A pattern can be constructed using braces:
>
> > for var in {1,2}:{a,b}; echo $var; end
> 1:a
> 2:a
> 1:b
> 2:b
This is the closest to what I want. Is there any way to get something like
this:
> for var in [something]; echo $var[1] "->" $var[2]; end
1 -> a
2 -> b
Where I can easily access each field separately (e.g. with array
subscripts)?
I know I can do
> for var in "1:a" "2:b"; echo $var; end
But that doesn't give me easy access the fields using array
indexing. The best I can think of right now is to define a separate
function get_fields (gf for short):
function gf --description Get\ one\ field\ from\ a\ colon\ separated\ field\
list.
echo $argv[1] | awk -F":" '{ print $'$argv[2]' }'
end
And then I can do this:
jagui...@salem /u/l/g/p/g/google3> for var in "1:a" "2:b"; echo (gf $var 1)
"->" (gf $var 2); end
1 -> a
2 -> b
Which is what I want, but maybe a little more verbose than my true desire.
-- James
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users