Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Apr 2010 21:20:05 GMT
From:      Jilles Tjoelker <jilles@stack.nl>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/68062: standalone repeat(1) command
Message-ID:  <201004252120.o3PLK5Wm050348@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/68062; it has been noted by GNATS.

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, cyrille.lefevre@laposte.net
Cc:  
Subject: Re: bin/68062: standalone repeat(1) command
Date: Sun, 25 Apr 2010 23:18:13 +0200

 I'm not sure if we want this repeat(1) command, given that csh(1)
 already has it as a builtin and a simple shell function can do it in
 sh(1).
 
 repeat() {
         local i="$1"
         shift
         while [ "$i" -gt 0 ]; do
                 "$@"
                 i=$((i-1))
         done
 }
 
 This shell function will cause expansions and redirections to be
 evaluated exactly once, but so do the csh builtin and your proposed
 external command.
 
 The closest to the repeat command that fits in sh's model is
 ksh93/bash/zsh's arithmetic for command, e.g.
   for ((i=0; i<3; i++)); do sync; done
 I usually use the arithmetic for command or loops like in the shell
 function above.
 
 zsh also has a repeat compound command much like csh, except that it
 will evaluate expansions and redirections for each execution of the
 command.
 
 -- 
 Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004252120.o3PLK5Wm050348>