summaryrefslogtreecommitdiff
path: root/bin
AgeCommit message (Collapse)Author
2020-10-19Add explicit casts to double to quiet a clang warning.Todd C. Miller
OK deraddt@
2020-10-15Explicitly skip a leading "/dev/" and do not rely on basename(3) andChristian Weisgerber
non-POSIX basename semantics. ok millert@
2020-10-07If we are asked to print the total number of blocks, do so even ifTodd C. Miller
we have no entries to print (either due to an empty directory or an error). This makes the -l and -s options more consistent, and matches the behavior of AT&T and GNU ls. From FreeBSD (das). OK kn@
2020-10-06I observed "csh i < file-containing-^T" to hit tenex(), which proceeds toTheo de Raadt
perform tty(4) ioctl operations against a non-tty. That is a pledge violation, you can only do a subset of tty(4) ioctl against a fd which references a tty device. Sidestep this problem if the input descriptor is not a tty ok anton millert
2020-10-05-f - can respresent both stdin and stdout; rework the text a littleJason McIntyre
to make it read better; reported by roderick ok millert
2020-10-03Use ferror() to check for write error, not the fflush() return value.Todd C. Miller
We can't rely on buffering to catch write errors in fflush(). Based on a diff from Demi M. Obenour, OK kn@
2020-09-20Clear screen before redrawing the line with ^L, also in input mode.Todd C. Miller
This is similar to the emacs mode clear-screen command. Unlike bash, but like zsh, ^L also works in input mode, not just command mode. OK kn@ tb@
2020-09-13Fix "$@" splitting with empty IFSTheo Buehler
One uncommon but useful way of writing shell scripts is to start off by disabling field/word splitting (IFS='') and pathname expansion/globbing (set -f), re-enabling either or both only for the commands that need them, e.g. within a subshell. This helps avoid a lot of snags with field splitting and globbing if you forget to quote a variable somewhere, adding to the general robustness of a script. (In fact it eliminates much of the need to quote variable/parameter expansions, with empty removal remaining as the only issue.) Unfortunately OpenBSD ksh (like all pdksh variants except mksh) has a POSIX compliance bug that is a show stopper for this approach: "$@" does not generate words (arguments) if IFS is empty. As a result, the separate command arguments represented by "$@" become a single argument. So passing on an intact set of positional parameters to a command or function is impossible with field splitting disabled. Of course this is illogical: the quoted special parameter "$@" generates zero or more words, it doesn't split any words, so the contents of IFS (or lack thereof) should be neither here nor there. It's old ksh88 behaviour copied by the original pdksh, but it violates POSIX and it has been fixed many years ago in ksh93 and all other POSIX shells. From Martijn Dekker (who also wrote the above paragraphs) back in 2016. Thanks to Avi Halachmi for reminding us of the issue. ok czarkoff deraadt kn
2020-08-30Fix multiple variable definitions to avoid errors with -fno-common.mortimer
ok millert@
2020-08-03clang10 identifies an argv[] comparison against '\0' instead of NULL,Theo de Raadt
it results in the same, but is incorrect. ok millert
2020-07-22Collapse consecutive stars to avoid exponential behavior.Todd C. Miller
OK tb@
2020-07-08Clarify that csh's -f flag is not just about .cshrc.Todd C. Miller
We don't need to be too specific about this in su(1), leave the details for csh(1). OK jca@
2020-07-07Add support for set -o pipefailJeremie Courreges-Anglas
With the pipefail option set, the exit status of a pipeline is 0 if all commands succeed, or the return status of the rightmost command that fails. This can help stronger error checking, but is not a silver bullet. For example, commands will exhibit a non-zero exit status if they're killed by a SIGPIPE when writing to a pipe. Yet pipefail was considered useful enough to be included in the next POSIX standard. This implementation remembers the value of the pipefail option when a pipeline is started, as described as option 1) in https://www.austingroupbugs.net/view.php?id=789#c4102 Requested by ajacoutot@, ok millert@
2020-07-06Always print the directory name in -R mode; matches historical behavior.Todd C. Miller
Previously, our ls would only print the directory name when listing more than one directory, which is the correct behavior for non-recursive ls but not for -R mode. OK deraadt@
2020-07-06Fix skipping of directories that begin with a '.' in -R mode.Todd C. Miller
It is not enough to avoid displaying the contents of the directory, we need to set FTS_SKIP to avoid descending into any subdirs too. Otherwise, if a ".foo" directory has a subdirectory "bar", ls will descend into bar and display its contents. OK deraadt@
2020-05-22Fix the exit code when eval()uating a || compound list, it wouldSebastian Benoit
terminate the shell when running under -e. See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=269067 and Bug reported including fix by Leah Neukirchen, Thanks! ok millert@
2020-05-17Change install images called *.fs to *.img. These are UFS filesystem images,Theo de Raadt
but additionally have a bootblock in the first 8K (since UFS does not use that space). There are some UEFI direct-from-internet bootloaders that require the name *.img. So this makes things more convenient for those, while keeping it consistant in all architectures. ok kettenis beck kn
2020-05-08Use proper function pointer type instead of void *Jeremie Courreges-Anglas
Mixing up function and void pointers isn't defined by POSIX or the C standard. POSIX only specifies that casting the result of dlsym(3) to an appropriate function pointer works. Avoid all this by using a typedef. from Michael Forney, ok tb@
2020-03-23in case we can't create intermediate directories because of permissions,Marc Espie
show a less confusing track okay millert@ (with a small tweak to the error message by millert@)
2020-02-25sleep(1): style(9) and other dustingcheloha
- Sort includes alphabetically - Sort prototypes alphabetically - Sort stack variables by size - Add missing braces to the getopt(3) loop - Be explicit: there is *one* argument, so use argv[0], not *argv - If nanosleep(2) somehow fails, say that "nanosleep" failed when we err(3) - Remove extra parentheses from the return statement - De-(void) the obvious fprintf(3) in usage() - __progname -> getprogname(3) - POSIX 1003.2 has long since become POSIX.1 - Remove an ARGUSED linter comment - stdio(3) flushing is not the only potential issue with an exit(3) from a signal handler. Just note that exit(3) isn't safe and leave it at that.
2020-02-21Enforce that TMOUT is an integer literal to prevent command execution fromTheo Buehler
the environment at shell initialization time. During startup, ksh calls 'eval typeset -i TMOUT="${TMOUT:-0}"'. which allows command injection via arithmetic expansion, e.g., by setting TMOUT to 'x[`/bin/echo Hi >&2`]'. Problem noted by Andras Farkas and tj, inspired by a similar issue in AT&T's ksh. Tested in snaps for two weeks. "go for it" deraadt
2020-02-14get rid of an awkward ellipsis noticed by Jan Stary; OK jmc@Ingo Schwarze
2020-02-14Do not mark up punctuation (equal signs), get rid of needless .Xo and .Sm,Ingo Schwarze
and make some wordings more concise. Parts of a patch from Jan Stary <hans at stare dot cz>, tweaked by me. Feedback and OK jmc@.
2020-02-10briefly mention /etc/examples/ in the FILES section of all theIngo Schwarze
manual pages that document the corresponding configuration files; OK jmc@, and general direction discussed with many
2020-02-09drop historical section number as was done in psJonathan Gray
2020-02-08Make HISTORY more concise: historical section numbers are irrelevant.Ingo Schwarze
Fluff noticed by jsg@.
2020-01-16Usually, -width Fl (which is 10n) is too wide and hence ugly.Ingo Schwarze
Change several instances, most of them to the usual -width Ds.
2020-01-09Rev 1.17 of sub.c removed infinite loop detection from s command.Alexander Bluhm
Adapt substitute test to new ed(1) behavior. Note that substitute result from sed(1) is still different.
2020-01-09Rev 1.59 of main.c allows omission of addresses in a range.Alexander Bluhm
Adapt ed test.
2020-01-09Rev 1.42 of main.c allows zero address for i command.Alexander Bluhm
Adapt ed test.
2019-12-16Delete tests for P_THREAD that predate the existence ofPhilip Guenther
KERN_PROC_SHOW_THREADS and have been rendered superfluous by it. Similarly, some P_SYSTEM tests can be deleted or pushed to the kernel by using KERN_PROC_ALL instead of KERN_PROC_KTHREAD. ok visa@ mpi@
2019-11-29typo fix.Nayden Markatchev
ok deraadt@
2019-11-26some corrections to CDPATH;Jason McIntyre
from chohag
2019-11-15In cpio mode, when processing the -o switch, only set the archive formatChristian Weisgerber
if not already set. This makes "cpio -Hustar -o" behave the same as "cpio -o -Hustar". ok guenther@
2019-10-27No need for <sys/uio.h> as writev(2) isn't used any more.Jeremie Courreges-Anglas
2019-10-27Don't fail hard if we can't preallocate history storage.Jeremie Courreges-Anglas
Using alloc.c for the history array brings no value and prevents easy handling of memory shortage. Switch to plain reallocarray and keep running if HISTSIZE is too big. The allocation is still done upfront with no sanity checking, it would probably be nicer to allocate space as needed. Issue reported by thomas@habets.se who suggested a different approach.
2019-09-06More Version 1 AT&T UNIX history.Ingo Schwarze
This became possible because copies of the original v1 manuals have shown up on the Internet some time ago. Reminded by Sevan Janiyan <venture37 at geeklan dot co dot uk>.
2019-09-05Document pledge keywordkn
OK millert
2019-09-02More correction of section 3 layout. directory->opendir, fts->fts_open,Theo de Raadt
getcap->cgetent. pwcache->user_from_uid. And then repair references. ok jmc
2019-08-08date(1): remove -d dst and -t minutes_westcheloha
Part of the kernel timezone removal effort. With input from deraadt@ and tedu@. "burn it!" mpi@, ok tedu@ deraadt@
2019-07-30In addresses, consistently use "+" rather than ".+1".Ingo Schwarze
Both have the same meaning, but the former is explicitly defined in this manual page as "the next line" whereas the latter requires combining various pieces of information for understanding. Unification suggested and patch OK'ed by martijn@.
2019-07-29Remove several .Xrs to section 2 and 3 that help little.Ingo Schwarze
Instead, link to the explanation of octal permission masks in chmod(2) directly from the description of "umask", and to ksh(1) from SEE ALSO. Fixing an oddity pointed out by guenther@; OK jmc@ millert@.
2019-07-26Replace cross-references to sigvec(3) with sigaction(2).Todd C. Miller
OK guenther@
2019-07-25tweak previous: a leading dash can only be given if an option letter follows;Ingo Schwarze
OK deraadt@
2019-07-24Years ago the optionality of leading - was removed. dash-less is aTheo de Raadt
fact on the ground in ps everywhere, even on linux, and it is not going to go away, and denying the existance is pointless. The SYNOPSIS cannot proscriptively document all the cases without a madness. I also feel there is very little need to explain the behaviour differences relative to the sparse POSIX standard for ps, everyone's ps has oodles of extensions.
2019-07-24Add #include <stdlib.h> for mkstemp.Brian Callahan
Spotted by maya@netbsd ok deraadt@
2019-07-201. Correct the description of the g command to match POSIX and ourIngo Schwarze
implementation; it was oversimplified and arguably incorrect. 2. Explicitely compare the behaviour of empty command lists for g, empty command lists for G, and empty commands because these subtle differences are quite confusing. 3. Say more precisely what the v and V commands do, avoiding the fuzzy wording "similar". All these issues were first pointed out by martijn@. Feedback and OK martijn@; "diff reads ok" jmc@ on an earlier version.
2019-07-15Explain in which circumstances trailing slashes can be omitted afterIngo Schwarze
the g and G commands, and polish the wording a bit explaining empty command lists. Closing a gap in the manual reported by <mazocomp at disroot dot org>. OK jmc@ martijn@
2019-07-12Minor polishing:Ingo Schwarze
* Delete a stray blank from the command line synopsis and add the missing .Ar markup to it. * Do not mention the terminating newline for the empty command since it isn't mentioned for any other command either. * Make the description of the empty command easier to understand. Joint work with martijn@ and jmc@.
2019-07-10document the dropping of the second / and ? in line address REs;Jason McIntyre
thread started by mazocomp; diff from ropers, shortened by me; ok martijn schwarze