summaryrefslogtreecommitdiffstats
path: root/bin/cat (follow)
Commit message (Collapse)AuthorAgeFilesLines
* cat(1): -n flag: correctly enumerate files with more than INT_MAX linescheloha2020-12-111-3/+4
| | | | | | | If we bump 'lines' from an int to an unsigned long long we can trivially support files with more than INT_MAX lines. ok millert@
* cat(1): misc. style(9)cheloha2020-12-041-11/+11
| | | | | | | - Use getprogname(3) instead of __progname. - Sprinkle in some missing braces. - Prefer err(..., NULL) when malloc(3) fails. - Remove an unnecessary cast to from ssize_t to size_t.
* cat(1): simplify argv processing loopscheloha2020-12-041-39/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | cook_args() and raw_args() do some peculiar things in order to avoid calling cook_buf() and raw_cat(), respectively, in more than one place. The result is a convoluted. If we isolate the special cases from the normal case and just call these functions in multiple places the loops will be easier to read. Three things: 1. Pull the no-args case out of the loop. If *argv is NULL when we get into the argv processing function we just want to operate on the standard input and return early. It makes no sense to handle this case *in* the loop. 2. Isolate the "-" case from the filename case. If *argv is "-" we want to operate on the standard input. We can then do any stdin-specific cleanup within the same branch, which makes it easier to understand both the "-" case and the normal filename case. This also allows us to remove the 'filename' intermediate variable from both argv processing functions. 3. While we're here, use a for-loop and iterate argv in the loop header. Now argv is incremented in one place. ok martijn@
* cat(1): remove global 'filename' variablecheloha2020-12-031-8/+9
| | | | | | | | There is no need for the global filename variable. Both cook_buf() and raw_cat() can accept a filename variable from the caller to use for printing warnings. ok martijn@
* When system calls indicate an error they return -1, not some arbitraryderaadt2019-06-281-4/+4
| | | | | | value < 0. errno is only updated in this case. Change all (most?) callers of syscalls to follow this better, and let's see if this strictness helps us in the future.
* More whitespace, helps readingjca2017-02-191-1/+2
| | | | ok ajacoutot@
* Delete useless setlocale(3) in src/bin/.schwarze2016-10-191-8/+3
| | | | | | Minor cleanup while here: return from main, static void __dead usage, etc. Based on a patch from Jan Stary <hans at stare dot cz>. Feedback and OK tb@, OK millert@.
* attempt to improve clarity by reducing forward references and moretedu2016-07-101-13/+10
| | | | directly documenting each option's effect.
* For -be, indent the $ on blank lines.schwarze2016-07-011-5/+11
| | | | | | | Patch from Giles Lean (NetBSD PR bin/4841), tweaked by kleink at NetBSD (rev. 1.17 1998-01-27), version for OpenBSD sent in by Sevan Janiyan <venture37 at geeklan dot co dot uk>. OK deraadt@
* replace setbuf with setvbuf, from Frederic Nowaktedu2015-11-042-6/+6
|
* Change all tame callers to namechange to pledge(2).deraadt2015-10-091-3/+3
|
* obvious tame "stdio rpath"deraadt2015-10-031-1/+4
| | | | ok semarie
* Replace <sys/param.h> with <limits.h> and other less dirty headers wherederaadt2015-01-161-3/+5
| | | | | | | | | possible. Annotate <sys/param.h> lines with their current reasons. Switch to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where sensible to avoid pulling in the pollution. These are the files confirmed through binary verification. ok guenther, millert, doug (helped with the verification protocol)
* remove .Tn; from Jan Stary <hans at stare dot cz>schwarze2015-01-151-7/+4
|
* where "-" represents stdin, just use Sq, not Fl, since it's not a flag;jmc2013-07-161-3/+3
| | | | from Jan Stary
* command-line (adj.) -> command line (n.);jmc2013-01-181-3/+3
|
* Shell output redirection truncating the destination fileschwarze2011-03-051-7/+15
| | | | | | | | is neither a bug nor a property of cat(1), so rename BUGS to CAVEATS. When showing a bad example, also tell the reader what to do instead. While here, use .Dl to display complete shell command lines, and - as suggested by jmc@ - avoid displays in the middle of sentences. feedback and ok jmc@
* add an EXIT STATUS section for /bin;jmc2010-09-031-3/+3
|
* rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andderaadt2009-10-271-15/+1
| | | | | | | unmaintainable). these days, people use source. these id's do not provide any benefit, and do hurt the small install media (the 33,000 line diff is essentially mechanical) ok with the idea millert, ok dms
* bump the posix reference in STANDARDS to IEEE Std 1003.1-2008, with a fewjmc2009-02-081-3/+3
| | | | updates to follow;
* replace hardcoded exit values with .Ex macros;sobrado2009-01-041-5/+3
| | | | ok jmc@
* sync usage(); from Tobias Stoeckmannjmc2007-07-171-3/+3
|
* convert to new .Dd format;jmc2007-05-311-2/+2
|
* - consistent STANDARDS blurbjmc2007-05-291-3/+3
| | | | | | - note which options are extensions to POSIX discussed w/ deraadt otto millert
* Fix handling of multiple stdin arguments in cooked mode, closes PR 5418.millert2007-03-221-3/+5
| | | | From Johan Veenhuizen
* change incorrect filename in output on fstat() failurejaredy2005-04-051-3/+3
| | | | | | from Cedric Berger <cedric@berger.to> ok otto
* - note that as well as tabs, the -v option does not display EOLsjmc2004-07-021-28/+29
| | | | | | | | | | | | from lkadosh at math dot ucr dot edu, via nick@ - put options in standard order - put explanations of examples before the examples, and indent examples - one i.e. -> e.g. as required additions/corrections/oks otto@ tom@ millert@
* minor cleanups / shut up lint, ok pedro tedujolan2004-05-211-10/+13
|
* Remove the advertising clause in the UCB license which Berkeleymillert2003-06-022-13/+5
| | | | rescinded 22 July 1999. Proofed by myself and Theo.
* Undo a misguided attempt to fix speling errors from long ago. UCBmillert2003-06-011-2/+2
| | | | | copyrights say "acknowledgement", not "acknowledgment". You cannot just go changing the text of a license willy-nilly.
* use .Li morederaadt2003-03-121-4/+4
|
* ansideraadt2002-07-041-13/+7
|
* Fix 'cat -se'; the '$' was not being printed for blank lines.millert2002-03-141-19/+14
| | | | Based on a patch from Denis Afonin.
* Part one of userland __P removal. Done with a simple regexp with some minor hand editing to make comments line up correctly. Another pass is forthcoming that handles the cases that could not be done automatically.millert2002-02-161-6/+6
|
* Initial patch.mpech2002-02-111-4/+4
| | | | | | | | | When you give command examples in a manual page prefix them with $ command or # command deraadt@ ok
* kill more registers;mpech2001-11-051-8/+8
| | | | millert@ ok
* o) __progname aria;mpech2001-09-061-3/+5
| | | | millert@ ok.
* Add some rudimentary EXAMPLES sections and standardize the way we displayaaron2000-10-181-16/+7
| | | | existing EXAMPLES sections.
* remove blank linepjanzen2000-08-051-2/+1
|
* Remove hard sentence breaks.aaron2000-03-171-8/+8
|
* An option description does not need to contain "The -foo option...".aaron2000-03-021-4/+2
|
* remove extra externs not needed because of unistd.h (rest of tree will be done later.. contact me if you want to help)deraadt2000-01-221-3/+2
|
* clarifyericj2000-01-121-2/+2
|
* Use the AT&T UNIX macros.aaron1999-10-171-2/+3
|
* more precise SYNOPSIS syntaxaaron1999-08-161-2/+2
|
* cat appeared in Version 1 AT&T UNIX, not 6aaron1999-07-231-3/+2
|
* correct use of .Nm; some other formatting nitsaaron1999-07-041-4/+5
|
* repairsaaron1999-05-301-3/+5
|
* repairsaaron1999-05-291-2/+3
|
* remove argument from .Os macros so value in /usr/share/tmac/mdoc/doc-commonaaron1999-05-231-2/+2
| | | | is used instead; kwesterback@home.com