From owner-freebsd-bugs@FreeBSD.ORG Thu Jun 17 23:10:36 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7802B16A4CE for ; Thu, 17 Jun 2004 23:10:36 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6713543D53 for ; Thu, 17 Jun 2004 23:10:36 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i5HNAQor093919 for ; Thu, 17 Jun 2004 23:10:26 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i5HNAQ07093918; Thu, 17 Jun 2004 23:10:26 GMT (envelope-from gnats) Resent-Date: Thu, 17 Jun 2004 23:10:26 GMT Resent-Message-Id: <200406172310.i5HNAQ07093918@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Cyrille Lefevre Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2CA7D16A4CF for ; Thu, 17 Jun 2004 23:00:56 +0000 (GMT) Received: from ioskeha.hittite.isp.9tel.net (ioskeha.hittite.isp.9tel.net [62.62.156.27]) by mx1.FreeBSD.org (Postfix) with ESMTP id 132BD43D2D for ; Thu, 17 Jun 2004 23:00:42 +0000 (GMT) (envelope-from root@gits.dyndns.org) Received: from mail.gits.dyndns.org (28-216-118-80.kaptech.net [80.118.216.28]) by ioskeha.hittite.isp.9tel.net (Postfix) with ESMTP id 4495F14B5B1 for ; Fri, 18 Jun 2004 01:02:06 +0200 (CEST) Received: from mail.gits.dyndns.org (IDENT:wuar34dpkdntxkxq@localhost [127.0.0.1])i5HMxaN9092445 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 18 Jun 2004 00:59:54 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by mail.gits.dyndns.org (8.12.11/8.12.11/Submit) id i5HMxaRa085055 for FreeBSD-gnats-submit@freebsd.org; Fri, 18 Jun 2004 00:59:36 +0200 (CEST) (envelope-from root) Message-Id: <20040617225935.GA10000@gits.dyndns.org> Date: Fri, 18 Jun 2004 00:59:35 +0200 From: Cyrille Lefevre To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/68062: standalone repeat(1) command X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Cyrille Lefevre List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2004 23:10:36 -0000 >Number: 68062 >Category: bin >Synopsis: standalone repeat(1) command >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Jun 17 23:10:26 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Cyrille Lefevre >Release: FreeBSD 5.2-CURRENT i386 >Organization: ACME >Environment: System: FreeBSD gits 5.2-CURRENT FreeBSD 5.2-CURRENT #29: Mon May 31 01:35:59 CEST 2004 root@gits:/disk3/freebsd/current/obj/disk3/freebsd/current/src/sys/CUSTOM i386 >Description: the standalone repeat(1) utility inpired from the csh(1) one. >How-To-Repeat: repeat 3 sync >Fix: Index: Makefile =================================================================== RCS file: /home/ncvs/src/share/man/man1/Makefile,v retrieving revision 1.17 diff -u -I$Id.*$ -I$.+BSD.*$ -r1.17 Makefile --- Makefile 20 Jan 2004 10:27:22 -0000 1.17 +++ Makefile 17 Jun 2004 22:22:34 -0000 @@ -61,7 +61,6 @@ builtin.1 read.1 \ builtin.1 readonly.1 \ builtin.1 rehash.1 \ - builtin.1 repeat.1 \ builtin.1 sched.1 \ builtin.1 set.1 \ builtin.1 setenv.1 \ # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # usr.bin/repeat/Makefile # usr.bin/repeat/repeat.1 # usr.bin/repeat/repeat.c # echo x - usr.bin/repeat/Makefile sed 's/^X//' >usr.bin/repeat/Makefile << 'END-of-usr.bin/repeat/Makefile' X# $FreeBSD$ X XPROG= repeat XWARNS?= 6 X X.include END-of-usr.bin/repeat/Makefile echo x - usr.bin/repeat/repeat.1 sed 's/^X//' >usr.bin/repeat/repeat.1 << 'END-of-usr.bin/repeat/repeat.1' X.\" Copyright (c) 2004 X.\" The Regents of the University of California. All rights reserved. X.\" X.\" This code is derived from software contributed to Berkeley by X.\" the Institute of Electrical and Electronics Engineers, Inc. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 4. Neither the name of the University nor the names of its contributors X.\" may be used to endorse or promote products derived from this software X.\" without specific prior written permission. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" @(#)apply.1 8.2 (Berkeley) 4/4/94 X.\" From: src/usr.bin/apply/apply.1,v 1.14 2002/04/19 23:16:06 charnier Exp X.\" $FreeBSD$ X.\" X.Dd June 17, 2004 X.Dt REPEAT 1 X.Os X.Sh NAME X.Nm repeat X.Nd repeat a command count times X.Sh SYNOPSIS X.Nm X.Ar count X.Ar command X.Op Ar argument ... X.Sh DESCRIPTION XThe X.Nm Xutility runs the named X.Ar command Xwith optional X.Ar argument , X.Pa count Xtimes. X.Sh DIAGNOSTICS X.Ex -std X.Sh SEE ALSO X.Xr csh 1 X.Sh HISTORY XThe X.Nm Xutility first appeared in X.Xr csh 1 . END-of-usr.bin/repeat/repeat.1 echo x - usr.bin/repeat/repeat.c sed 's/^X//' >usr.bin/repeat/repeat.c << 'END-of-usr.bin/repeat/repeat.c' X/*- X * Copyright (c) 2004 X * The Regents of the University of California. All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 4. Neither the name of the University nor the names of its contributors X * may be used to endorse or promote products derived from this software X * without specific prior written permission. X * X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X#include X__FBSDID("$FreeBSD$"); X X#include X#include X X#include X#include X#include X#include X#include X#include X Xstatic int exec_cmd(const char *, char *const *); Xstatic void usage(void) __dead2; X Xint Xmain(int argc, char *const argv[]) X{ X char *endp; X long count; X int rval; X X if (argc < 2) X usage(); X X count = strtol(argv[1], &endp, 10); X if (errno == ERANGE || endp == argv[1] || *endp || count < 0) X errx(1, "%s: badly formed number.", argv[1]); X X for (rval = 0; count > 0; count--) X if (exec_cmd(argv[2], &argv[2])) X rval = 1; X X exit(rval); X} X X/* X * based on exec_shell() from apply(1). X * exec_cmd -- X * Execute a command using passed arguments. X */ Xstatic int Xexec_cmd(const char *command, char *const *argv) X{ X pid_t pid; X int omask, pstat; X sig_t intsave, quitsave; X X if (!argv || !argv[0]) /* just checking... */ X return(1); X X omask = sigblock(sigmask(SIGCHLD)); X switch(pid = vfork()) { X case -1: /* error */ X err(1, "vfork"); X case 0: /* child */ X (void)sigsetmask(omask); X execvp(command, argv); X warn("%s", command); X _exit(1); X } X intsave = signal(SIGINT, SIG_IGN); X quitsave = signal(SIGQUIT, SIG_IGN); X pid = waitpid(pid, &pstat, 0); X (void)sigsetmask(omask); X (void)signal(SIGINT, intsave); X (void)signal(SIGQUIT, quitsave); X return(pid == -1 ? -1 : pstat); X} X Xstatic void Xusage(void) X{ X X (void)fprintf(stderr, "usage: repeat count command [argument ...]\n"); X exit(1); X} END-of-usr.bin/repeat/repeat.c exit >Release-Note: >Audit-Trail: >Unformatted: