summaryrefslogtreecommitdiffstats
path: root/bin/cat
AgeCommit message (Collapse)AuthorFilesLines
2020-12-11cat(1): -n flag: correctly enumerate files with more than INT_MAX linescheloha1-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@
2020-12-04cat(1): misc. style(9)cheloha1-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.
2020-12-04cat(1): simplify argv processing loopscheloha1-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@
2020-12-03cat(1): remove global 'filename' variablecheloha1-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@
2019-06-28When system calls indicate an error they return -1, not some arbitraryderaadt1-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.
2017-02-19More whitespace, helps readingjca1-1/+2
ok ajacoutot@
2016-10-19Delete useless setlocale(3) in src/bin/.schwarze1-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@.
2016-07-10attempt to improve clarity by reducing forward references and moretedu1-13/+10
directly documenting each option's effect.
2016-07-01For -be, indent the $ on blank lines.schwarze1-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@
2015-11-04replace setbuf with setvbuf, from Frederic Nowaktedu2-6/+6
2015-10-09Change all tame callers to namechange to pledge(2).deraadt1-3/+3
2015-10-03obvious tame "stdio rpath"deraadt1-1/+4
ok semarie
2015-01-16Replace <sys/param.h> with <limits.h> and other less dirty headers wherederaadt1-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)
2015-01-15remove .Tn; from Jan Stary <hans at stare dot cz>schwarze1-7/+4
2013-07-16where "-" represents stdin, just use Sq, not Fl, since it's not a flag;jmc1-3/+3
from Jan Stary
2013-01-18command-line (adj.) -> command line (n.);jmc1-3/+3
2011-03-05Shell output redirection truncating the destination fileschwarze1-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@
2010-09-03add an EXIT STATUS section for /bin;jmc1-3/+3
2009-10-27rcsid[] and sccsid[] and copyright[] are essentially unmaintained (andderaadt1-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
2009-02-08bump the posix reference in STANDARDS to IEEE Std 1003.1-2008, with a fewjmc1-3/+3
updates to follow;
2009-01-04replace hardcoded exit values with .Ex macros;sobrado1-5/+3
ok jmc@
2007-07-17sync usage(); from Tobias Stoeckmannjmc1-3/+3
2007-05-31convert to new .Dd format;jmc1-2/+2
2007-05-29- consistent STANDARDS blurbjmc1-3/+3
- note which options are extensions to POSIX discussed w/ deraadt otto millert
2007-03-22Fix handling of multiple stdin arguments in cooked mode, closes PR 5418.millert1-3/+5
From Johan Veenhuizen
2005-04-05change incorrect filename in output on fstat() failurejaredy1-3/+3
from Cedric Berger <cedric@berger.to> ok otto
2004-07-02- note that as well as tabs, the -v option does not display EOLsjmc1-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@
2004-05-21minor cleanups / shut up lint, ok pedro tedujolan1-10/+13
2003-06-02Remove the advertising clause in the UCB license which Berkeleymillert2-13/+5
rescinded 22 July 1999. Proofed by myself and Theo.
2003-06-01Undo a misguided attempt to fix speling errors from long ago. UCBmillert1-2/+2
copyrights say "acknowledgement", not "acknowledgment". You cannot just go changing the text of a license willy-nilly.
2003-03-12use .Li morederaadt1-4/+4
2002-07-04ansideraadt1-13/+7
2002-03-14Fix 'cat -se'; the '$' was not being printed for blank lines.millert1-19/+14
Based on a patch from Denis Afonin.
2002-02-16Part 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.millert1-6/+6
2002-02-11Initial patch.mpech1-4/+4
When you give command examples in a manual page prefix them with $ command or # command deraadt@ ok
2001-11-05kill more registers;mpech1-8/+8
millert@ ok
2001-09-06o) __progname aria;mpech1-3/+5
millert@ ok.
2000-10-18Add some rudimentary EXAMPLES sections and standardize the way we displayaaron1-16/+7
existing EXAMPLES sections.
2000-08-05remove blank linepjanzen1-2/+1
2000-03-17Remove hard sentence breaks.aaron1-8/+8
2000-03-02An option description does not need to contain "The -foo option...".aaron1-4/+2
2000-01-22remove extra externs not needed because of unistd.h (rest of tree will be done later.. contact me if you want to help)deraadt1-3/+2
2000-01-12clarifyericj1-2/+2
1999-10-17Use the AT&T UNIX macros.aaron1-2/+3
1999-08-16more precise SYNOPSIS syntaxaaron1-2/+2
1999-07-23cat appeared in Version 1 AT&T UNIX, not 6aaron1-3/+2
1999-07-04correct use of .Nm; some other formatting nitsaaron1-4/+5
1999-05-30repairsaaron1-3/+5
1999-05-29repairsaaron1-2/+3
1999-05-23remove argument from .Os macros so value in /usr/share/tmac/mdoc/doc-commonaaron1-2/+2
is used instead; kwesterback@home.com