FreeBSD Bugzilla – Attachment 43895 Details for
Bug 68062
standalone repeat(1) command
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
file.shar
file.shar (text/plain), 6.24 KB, created by
Cyrille Lefevre
on 2004-06-18 00:10:26 UTC
(
hide
)
Description:
file.shar
Filename:
MIME Type:
Creator:
Cyrille Lefevre
Created:
2004-06-18 00:10:26 UTC
Size:
6.24 KB
patch
obsolete
># 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 <bsd.prog.mk> >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 <sys/cdefs.h> >X__FBSDID("$FreeBSD$"); >X >X#include <sys/types.h> >X#include <sys/wait.h> >X >X#include <err.h> >X#include <errno.h> >X#include <signal.h> >X#include <stdio.h> >X#include <stdlib.h> >X#include <unistd.h> >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
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 68062
:
43894
| 43895