History log of /freebsd-current/usr.bin/apply/apply.c
Revision Date Author Comments
# 5e3934b1 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# bdcbfde3 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

usr.bin: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 441202c0 08-Aug-2022 Dag-Erling Smørgrav <des@FreeBSD.org>

apply: clean up error handling.

Sponsored by: Klara, Inc.


# f032f7b3 08-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

apply(1): Fix magic number substitution with magic character ' '

Using a space as the magic character would result in problems if the command
started with a number:

- For a 'valid' number n, n < size of argv, it would erroneously get
replaced with that argument; e.g. `apply -a ' ' -d 1rm x => `execxrm x`

- For an 'invalid' number n, n >= size of argv, it would segfault.
e.g. `apply -a ' ' 2to3 test.py` would try to access argv[2]

This problem occurred because apply(1) would prepend "exec " to the command
string before doing the actual magic number replacements, so it would come
across "exec 2to3 1" and assume that the " 2" is also a magic number to be
replaced.

Re-work this to instead just append "exec " to the command sbuf and
workaround the ugliness. This also simplifies stuff in the process.

PR: 226948
Submitted by: Tobias Stoeckmann <tobias@stoeckmann.org>
MFC after: 1 week


# 8a16b7a1 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# befcdd43 04-Jan-2013 Xin LI <delphij@FreeBSD.org>

Constify arguments. While I'm there, also add a static for usage().

MFC after: 2 weeks


# da52b4ca 11-Dec-2010 Joel Dahl <joel@FreeBSD.org>

Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with: imp, rwatson


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# 12794df2 05-Mar-2010 Jaakko Heinonen <jh@FreeBSD.org>

- Use errx(3) instead of err(3) when checking if snprintf(3) succeeded.
snprintf(3) doesn't set errno in the tested cases.
- If the same argument reference (for example %1) was specified more than
once, the command didn't necessarily fit to the final command buffer. Fix
this using a dynamic sbuf buffer. Add a few regression tests for the case.

PR: bin/95079
No objections: freebsd-hackers


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 3adb4d32 09-Jun-2003 Philippe Charnier <charnier@FreeBSD.org>

Revert previous commit, from Bruce:
This is a style bug. err() is declared is non-returning so that every
use of it doesn't need to be encrufted with NOTREACHED. It's too bad
that only gcc understands the declaration.

Asked by: bde@


# 5288a06a 08-Jun-2003 Philippe Charnier <charnier@FreeBSD.org>

Add NOTREACHED after err() inside of a switch statement.


# da8de1e2 14-Jul-2002 Alfred Perlstein <alfred@FreeBSD.org>

WARNS=4


# 9f5b04e9 10-Dec-2001 David Malone <dwmalone@FreeBSD.org>

Style improvements recommended by Bruce as a follow up to some
of the recent WARNS commits. The idea is:

1) FreeBSD id tags should follow vendor tags.
2) Vendor tags should not be compiled (though copyrights probably should).
3) There should be no blank line between including cdefs and __FBSDIF.


# 4100f6cb 02-Dec-2001 Mark Murray <markm@FreeBSD.org>

Use __FBSDID().


# 08741a6f 20-Aug-2001 Brian Somers <brian@FreeBSD.org>

Revert to version 1.16 which was more correct than either of my attempts.


# 051449d5 21-Aug-2001 Brian Somers <brian@FreeBSD.org>

Remove unnecessary casts.

The original (1.16) code was mostly correct, but this version is
far clearer.

Casts suggested to now be obfuscations by: bde


# cbe1d3b6 20-Aug-2001 Brian Somers <brian@FreeBSD.org>

Handle snprintf() returning -1.

MFC after: 2 weeks


# 7bc6d015 09-Jul-2001 Brian Somers <brian@FreeBSD.org>

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# 34bc43d5 24-Jan-2001 Will Andrews <will@FreeBSD.org>

Fix bogus checking of snprintf() by decreasing the remaining size of the
string after each successful snprintf() call. This makes apply(1) work
*correctly*, although the whole snprintf() deal really should be redone.

Bug noted by: nectar (about 3 weeks ago)


# cdc8ffbb 21-Jan-2001 Will Andrews <will@FreeBSD.org>

Fix numerous style(9) bugs: Put #define's before declarations; sort the
declarations & their arguments; use only one tab after types; restore the
type of argv to sync with src tree style; sort new variables under main();
fix continuation indents; remove extra blank line before free()'s. Still
to do: fix snprintf() handling as nectar & bde suggested to me.

Submitted by: bde


# f6973480 05-Jan-2001 Will Andrews <will@FreeBSD.org>

Reinstate revision 1.11:
BDECFLAGS; ANSIfy; use EXEC instead of "exec " where appropriate; use
proper types (size_t, int); use proper variable names for certain things;
get rid of static 'cache' style stuff by moving and sanitizing the
original SHELL checking code to main(), this also makes it easier to
free() the string; rename file-scope system() to exec_shell(); use
snprintf() everywhere instead of sprintf(); actually remember to free()
other malloc()'d char pointers in main().

I left out the -s option in this revision along with getusershell()
checking because of objections made by Warner Losh <imp> and Garrett
Wollman <wollman>. I agreed with their assertions that such code was
unnecessary in a program like this.

I dare people to make this coredump now.

Some suggestions: nectar (snprintf() truncate checking)
Reviewed by: markm, eivind, jedgar
Tortured by: examples in apply(1), fuzz(1),
and a lot of random ideas I came up with


# 9861e6df 04-Jan-2001 Will Andrews <will@FreeBSD.org>

Back out last commit; it had string function mistakes. I will fix this
and make sure it works next time.

Submitted by: markm, jhb


# c494ed80 04-Jan-2001 Will Andrews <will@FreeBSD.org>

BDECFLAGS; de-__P()-ify, ANSIfy, use snprintf() instead of sprintf(),
especially on strings passed from argv; rename system() to exec_shell(),
and make it static; use strlcpy() and make sure it works; use proper
type (size_t) to be passed to malloc()/realloc().

Use getusershell() to make sure the SHELL environment variable passed is
safe to use. Add new option -s to allow anal users to pass things like
perl; this option is here along with getusershell() checking since the
such checking is only intended to affect things like suidperl that might
call apply(1).

Reviewed by: markm, jhb, C. Stephen Gunn <csg@waterspout.com>


# aab65414 16-Oct-2000 Brian Somers <brian@FreeBSD.org>

Include sys/types.h


# 6ad13586 19-May-2000 Kris Kennaway <kris@FreeBSD.org>

fork() -> vfork()

This would have been commit #2 which was "Obtained from: BSD/OS" except
their code is buggy (they call err() if the execl() fails, which will
incorrectly call exit()), so instead this is:

Obtained from: NetBSD


# 6ec34d21 05-Dec-1999 Philippe Charnier <charnier@FreeBSD.org>

Do not dot terminate errx() strings. Add rcsid.
Document -d flag. Rework SYNOPSIS section


# b26a5ea6 03-Dec-1999 Kris Kennaway <kris@FreeBSD.org>

Fix off-by-one error leading to a segfault.

Noticed by: Thomas Stromberg <tstromberg@rtci.com>


# ec10002d 12-Feb-1999 Eivind Eklund <eivind@FreeBSD.org>

Merge from OpenBSD up to rev 1.5 (matches NetBSD up to rev 1.3):
* Clean up waitpid parameter handling.


# fa146c53 06-Dec-1998 Archie Cobbs <archie@FreeBSD.org>

Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]).


# 1fd98d7d 13-Oct-1998 Dag-Erling Smørgrav <des@FreeBSD.org>

Calls one or more of malloc(), warn(), err(), syslog(), execlp() or
execvp() in the child branch of a vfork(). Changed to use fork()
instead.

Some of these (mv, find, apply, xargs) might benefit greatly from
being rewritten to use vfork() properly.

PR: Loosely related to bin/8252
Approved by: jkh and bde


# 1c8af878 28-Mar-1997 Warner Losh <imp@FreeBSD.org>

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


# 7799f52a 30-May-1995 Rodney W. Grimes <rgrimes@FreeBSD.org>

Remove trailing whitespace.


# 9b50d902 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Usr.bin Sources