aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/apply/apply.c
Commit message (Collapse)AuthorAgeFilesLines
* usr.bin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-4/+0
| | | | | | | | | | | | | | | | 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
* usr.bin: Remove ancient SCCS tags.Warner Losh2023-11-271-3/+0
| | | | | | | | 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
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* apply: clean up error handling.Dag-Erling Smørgrav2022-08-081-7/+8
| | | | Sponsored by: Klara, Inc.
* apply(1): Fix magic number substitution with magic character ' 'Kyle Evans2018-08-081-24/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=337504
* General further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-201-0/+2
| | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326025
* Renumber copyright clause 4Warner Losh2017-02-281-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=314436
* Constify arguments. While I'm there, also add a static for usage().Xin LI2013-01-041-3/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=245048
* Remove the advertising clause from UCB copyrighted files in usr.bin. ThisJoel Dahl2010-12-111-4/+0
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=216370
* - Use errx(3) instead of err(3) when checking if snprintf(3) succeeded.Jaakko Heinonen2010-03-051-35/+32
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=204761
* Revert previous commit, from Bruce:Philippe Charnier2003-06-091-1/+0
| | | | | | | | | | | 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@ Notes: svn path=/head/; revision=116109
* Add NOTREACHED after err() inside of a switch statement.Philippe Charnier2003-06-081-0/+1
| | | | Notes: svn path=/head/; revision=116043
* WARNS=4Alfred Perlstein2002-07-141-1/+1
| | | | Notes: svn path=/head/; revision=99984
* Style improvements recommended by Bruce as a follow up to someDavid Malone2001-12-101-5/+6
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=87628
* Use __FBSDID().Mark Murray2001-12-021-5/+4
| | | | Notes: svn path=/head/; revision=87231
* Revert to version 1.16 which was more correct than either of my attempts.Brian Somers2001-08-211-4/+4
| | | | Notes: svn path=/head/; revision=82057
* Remove unnecessary casts.Brian Somers2001-08-211-4/+4
| | | | | | | | | | The original (1.16) code was mostly correct, but this version is far clearer. Casts suggested to now be obfuscations by: bde Notes: svn path=/head/; revision=82051
* Handle snprintf() returning -1.Brian Somers2001-08-201-4/+4
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=81979
* Fix the type of the NULL arg to execl()Brian Somers2001-07-091-1/+1
| | | | | | | Idea from: Theo de Raadt <deraadt@openbsd.org> Notes: svn path=/head/; revision=79452
* Fix bogus checking of snprintf() by decreasing the remaining size of theWill Andrews2001-01-251-0/+3
| | | | | | | | | | 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) Notes: svn path=/head/; revision=71615
* Fix numerous style(9) bugs: Put #define's before declarations; sort theWill Andrews2001-01-211-12/+11
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=71326
* Reinstate revision 1.11:Will Andrews2001-01-051-37/+62
| | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=70692
* Back out last commit; it had string function mistakes. I will fix thisWill Andrews2001-01-041-40/+23
| | | | | | | | | and make sure it works next time. Submitted by: markm, jhb Notes: svn path=/head/; revision=70672
* BDECFLAGS; de-__P()-ify, ANSIfy, use snprintf() instead of sprintf(),Will Andrews2001-01-041-23/+40
| | | | | | | | | | | | | | | | | 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> Notes: svn path=/head/; revision=70669
* Include sys/types.hBrian Somers2000-10-161-0/+2
| | | | Notes: svn path=/head/; revision=67189
* fork() -> vfork()Kris Kennaway2000-05-191-3/+4
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=60706
* Do not dot terminate errx() strings. Add rcsid.Philippe Charnier1999-12-051-3/+3
| | | | | | | Document -d flag. Rework SYNOPSIS section Notes: svn path=/head/; revision=54157
* Fix off-by-one error leading to a segfault.Kris Kennaway1999-12-041-1/+5
| | | | | | | Noticed by: Thomas Stromberg <tstromberg@rtci.com> Notes: svn path=/head/; revision=54113
* Merge from OpenBSD up to rev 1.5 (matches NetBSD up to rev 1.3):Eivind Eklund1999-02-121-4/+3
| | | | | | | * Clean up waitpid parameter handling. Notes: svn path=/head/; revision=43928
* Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]).Archie Cobbs1998-12-061-1/+1
| | | | Notes: svn path=/head/; revision=41568
* Calls one or more of malloc(), warn(), err(), syslog(), execlp() orDag-Erling Smørgrav1998-10-131-1/+1
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=40301
* compare return value from getopt against -1 rather than EOF, per the finalWarner Losh1997-03-291-1/+1
| | | | | | | posix standard on the topic. Notes: svn path=/head/; revision=24360
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-1/+1
| | | | Notes: svn path=/head/; revision=8874
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+234
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590