From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 25 21:20:06 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 438E2106568C for ; Sun, 25 Apr 2010 21:20:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 319628FC1D for ; Sun, 25 Apr 2010 21:20:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o3PLK55m050354 for ; Sun, 25 Apr 2010 21:20:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o3PLK5Wm050348; Sun, 25 Apr 2010 21:20:05 GMT (envelope-from gnats) Date: Sun, 25 Apr 2010 21:20:05 GMT Message-Id: <201004252120.o3PLK5Wm050348@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jilles Tjoelker Cc: Subject: Re: bin/68062: standalone repeat(1) command X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jilles Tjoelker List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Apr 2010 21:20:06 -0000 The following reply was made to PR bin/68062; it has been noted by GNATS. From: Jilles Tjoelker 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