* duplicating functions
@ 2005-10-20 9:35 zzapper
2005-10-20 11:59 ` Jean Chalard
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: zzapper @ 2005-10-20 9:35 UTC (permalink / raw)
To: zsh-users
Hi,
I have a series of functions defined .zshenv
function g0() { gmark $0 $* }
function g1() { gmark $0 $* }
function g2() { gmark $0 $* }
function g3() { gmark $0 $* }
function g4() { gmark $0 $* }
function g5() { gmark $0 $* }
function g6() { gmark $0 $* }
function g7() { gmark $0 $* }
function g8() { gmark $0 $* }
function g9() { gmark $0 $* }
Where gmark contains the code and $0 is used to determine which original function was called
Is there are simpler way of doing this
--
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: duplicating functions
2005-10-20 9:35 duplicating functions zzapper
@ 2005-10-20 11:59 ` Jean Chalard
2005-10-20 12:05 ` zzapper
2005-10-20 14:33 ` Bart Schaefer
2005-10-20 16:13 ` Andrey Borzenkov
2 siblings, 1 reply; 10+ messages in thread
From: Jean Chalard @ 2005-10-20 11:59 UTC (permalink / raw)
To: zzapper; +Cc: zsh-users
> I have a series of functions defined .zshenv
>
> function g0() { gmark $0 $* }
> function g1() { gmark $0 $* }
> function g2() { gmark $0 $* }
> function g3() { gmark $0 $* }
> function g4() { gmark $0 $* }
> function g5() { gmark $0 $* }
> function g6() { gmark $0 $* }
> function g7() { gmark $0 $* }
> function g8() { gmark $0 $* }
> function g9() { gmark $0 $* }
>
> Where gmark contains the code and $0 is used to determine which original
> function was called
>
> Is there are simpler way of doing this
What about the following :
for i in g{0..9}; do function $i() { gmark $0 $* }; done
--
J
"If you wish to leave a record of your call,
please state your messij at the sound of the tone."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: duplicating functions
2005-10-20 11:59 ` Jean Chalard
@ 2005-10-20 12:05 ` zzapper
0 siblings, 0 replies; 10+ messages in thread
From: zzapper @ 2005-10-20 12:05 UTC (permalink / raw)
To: zsh-users
On Thu, 20 Oct 2005 20:59:14 +0900, wrote:
>for i in g{0..9}; do function $i() { gmark $0 $* }; done
That is so kool!
--
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: duplicating functions
2005-10-20 9:35 duplicating functions zzapper
2005-10-20 11:59 ` Jean Chalard
@ 2005-10-20 14:33 ` Bart Schaefer
2005-10-20 16:13 ` Andrey Borzenkov
2 siblings, 0 replies; 10+ messages in thread
From: Bart Schaefer @ 2005-10-20 14:33 UTC (permalink / raw)
To: zsh-users
You can define multiple function names having the same function body
with a single "function" command (or with a single pair of empty
parens, if you're using the other syntax). This is one of the reasons
that the alias/function conflict is so insidious; if you have
alias foo='noglob bar'
foo() { print oops }
you get two functions that print oops, one of which supercedes the
noglob modifier, and neither of which is named foo.
However, in a case like yours, that quirk is potentially useful:
function g{0..9} { gmark $0 $* }
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: duplicating functions
2005-10-20 9:35 duplicating functions zzapper
2005-10-20 11:59 ` Jean Chalard
2005-10-20 14:33 ` Bart Schaefer
@ 2005-10-20 16:13 ` Andrey Borzenkov
2005-10-21 8:35 ` zzapper
2 siblings, 1 reply; 10+ messages in thread
From: Andrey Borzenkov @ 2005-10-20 16:13 UTC (permalink / raw)
To: zsh-users; +Cc: zzapper
[-- Attachment #1: Type: text/plain, Size: 718 bytes --]
On Thursday 20 October 2005 13:35, zzapper wrote:
> Hi,
> I have a series of functions defined .zshenv
>
> function g0() { gmark $0 $* }
> function g1() { gmark $0 $* }
> function g2() { gmark $0 $* }
> function g3() { gmark $0 $* }
> function g4() { gmark $0 $* }
> function g5() { gmark $0 $* }
> function g6() { gmark $0 $* }
> function g7() { gmark $0 $* }
> function g8() { gmark $0 $* }
> function g9() { gmark $0 $* }
>
> Where gmark contains the code and $0 is used to determine which original
> function was called
>
> Is there are simpler way of doing this
function g{0..9} { gmark $0 $* }
but I still do not understand what's wrong with calling "gmark gN ..."
directly
-andrey
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: duplicating functions
2005-10-20 16:13 ` Andrey Borzenkov
@ 2005-10-21 8:35 ` zzapper
2005-10-21 14:48 ` Speedy directory generation Meino Christian Cramer
0 siblings, 1 reply; 10+ messages in thread
From: zzapper @ 2005-10-21 8:35 UTC (permalink / raw)
To: zsh-users
On Thu, 20 Oct 2005 20:13:20 +0400, wrote:
>On Thursday 20 October 2005 13:35, zzapper wrote:
>> Hi,
>> I have a series of functions defined .zshenv
>>
>> function g0() { gmark $0 $* }
>> function g1() { gmark $0 $* }
>> function g2() { gmark $0 $* }
>> function g3() { gmark $0 $* }
>> function g4() { gmark $0 $* }
>> function g5() { gmark $0 $* }
>> function g6() { gmark $0 $* }
>> function g7() { gmark $0 $* }
>> function g8() { gmark $0 $* }
>> function g9() { gmark $0 $* }
>>
>> Where gmark contains the code and $0 is used to determine which original
>> function was called
>>
>> Is there are simpler way of doing this
>
>function g{0..9} { gmark $0 $* }
>
>but I still do not understand what's wrong with calling "gmark gN ..."
>directly
>
>-andrey
Andrey,
Because I'm obsessed with typing the minimum numbers of characters <G> like many *nixers
--
zzapper
Success for Techies and Vim,Zsh tips
http://SuccessTheory.com/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Speedy directory generation
2005-10-21 8:35 ` zzapper
@ 2005-10-21 14:48 ` Meino Christian Cramer
2005-10-21 14:52 ` Peter Stephenson
[not found] ` <20051021145708.GV4387@wu.physik.uni-dortmund.de>
0 siblings, 2 replies; 10+ messages in thread
From: Meino Christian Cramer @ 2005-10-21 14:48 UTC (permalink / raw)
To: zsh-users
Hi,
I want to mkdir directories named 001,002,003,004....100.
Is there a quick hack with zsh to do so? I tried ranges
"<001-100>" and such but failed.
Thank you very much for any help!
Have a nice weekend !
mcc
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Speedy directory generation
2005-10-21 14:48 ` Speedy directory generation Meino Christian Cramer
@ 2005-10-21 14:52 ` Peter Stephenson
2005-10-21 15:14 ` Meino Christian Cramer
[not found] ` <20051021145708.GV4387@wu.physik.uni-dortmund.de>
1 sibling, 1 reply; 10+ messages in thread
From: Peter Stephenson @ 2005-10-21 14:52 UTC (permalink / raw)
To: zsh-users
Meino Christian Cramer wrote:
> Hi,
>
> I want to mkdir directories named 001,002,003,004....100.
>
> Is there a quick hack with zsh to do so? I tried ranges
> "<001-100>" and such but failed.
mkdir {001..100}
pws
This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Speedy directory generation
2005-10-21 14:52 ` Peter Stephenson
@ 2005-10-21 15:14 ` Meino Christian Cramer
0 siblings, 0 replies; 10+ messages in thread
From: Meino Christian Cramer @ 2005-10-21 15:14 UTC (permalink / raw)
To: pws; +Cc: zsh-users
From: Peter Stephenson <pws@csr.com>
Subject: Re: Speedy directory generation
Date: Fri, 21 Oct 2005 15:52:51 +0100
Damn...this permutation I didn't check. :)
Thanks a lot!
Have a nice weekend!
mcc
> Meino Christian Cramer wrote:
> > Hi,
> >
> > I want to mkdir directories named 001,002,003,004....100.
> >
> > Is there a quick hack with zsh to do so? I tried ranges
> > "<001-100>" and such but failed.
>
> mkdir {001..100}
>
> pws
>
>
> This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Speedy directory generation
[not found] ` <20051021145708.GV4387@wu.physik.uni-dortmund.de>
@ 2005-10-21 15:18 ` Meino Christian Cramer
0 siblings, 0 replies; 10+ messages in thread
From: Meino Christian Cramer @ 2005-10-21 15:18 UTC (permalink / raw)
To: wacker; +Cc: zsh-users
From: Klaus Wacker <wacker@physik.uni-dortmund.de>
Subject: Re: Speedy directory generation
Date: Fri, 21 Oct 2005 16:57:08 +0200
Hi,
thanks a lot.
This permutation I didn't try... :)
have a nice weekend!
mcc
> On Fri, Oct 21, 2005 at 04:48:33PM +0200, Meino Christian Cramer wrote:
> >
> > Hi,
> >
> > I want to mkdir directories named 001,002,003,004....100.
> >
> > Is there a quick hack with zsh to do so? I tried ranges
> > "<001-100>" and such but failed.
> >
>
> {001..100} should work. It just generates to the range of numbers.
> <001-100> matches existing files in that range.
>
> Klaus
>
> --
> Klaus Wacker wacker@Physik.Uni-Dortmund.DE
> Experimentelle Physik V http://www.physik.uni-dortmund.de/~wacker
> Universitaet Dortmund Tel.: +49 231 755 3587
> D-44221 Dortmund Fax: +49 231 755 4547
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-10-21 15:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-20 9:35 duplicating functions zzapper
2005-10-20 11:59 ` Jean Chalard
2005-10-20 12:05 ` zzapper
2005-10-20 14:33 ` Bart Schaefer
2005-10-20 16:13 ` Andrey Borzenkov
2005-10-21 8:35 ` zzapper
2005-10-21 14:48 ` Speedy directory generation Meino Christian Cramer
2005-10-21 14:52 ` Peter Stephenson
2005-10-21 15:14 ` Meino Christian Cramer
[not found] ` <20051021145708.GV4387@wu.physik.uni-dortmund.de>
2005-10-21 15:18 ` Meino Christian Cramer
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).