summaryrefslogtreecommitdiffstats
path: root/bin (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Provide definition of CTRL in vi.c like we do for emacs.c.millert2021-03-121-1/+4
| | | | Fixes a portability issue. From Benjamin Baier
* groff complains about the word "An" in an Rs/Re block, believing it a macro,jmc2021-03-111-3/+3
| | | | so escape it;
* Add support for ^R (redraw) in insert mode too.millert2021-03-102-3/+9
| | | | From gotroyb127, OK tb@
* Fix redrawing of a multiline PS1 prompt in vi mode.millert2021-03-101-8/+9
| | | | From gotroyb127 OK tb@
* use a journal reference instead of cstr when possiblejsg2021-03-081-1/+9
|
* Add some references, most of these were removed when we stopped buildingjsg2021-03-083-6/+30
| | | | | | and installing USD/SMM/PSD docs. jmc@ agrees with the direction, ok millert@ on an earlier diff
* Fix old ksh bug: wrong variable being looked up when value is provided.zhuk2021-03-051-2/+2
| | | | | | | This results, e.g., in allowing the first item of a read-only array to be overwritten, as found by Jordan Geoghegan. okay tb@
* 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@
* replace the "write a floppy image" example with a more up to date one;jmc2020-10-291-5/+6
| | | | input/ok deraadt jca
* In lib/libc/gen/charclass.h r1.3 guenther made cclasses const.tb2020-10-261-2/+2
| | | | | | | | Mark the pointer used to walk the array in ksh const as well. From Matthew Martin ok guenther
* Add explicit casts to double to quiet a clang warning.millert2020-10-191-2/+2
| | | | OK deraddt@
* Explicitly skip a leading "/dev/" and do not rely on basename(3) andnaddy2020-10-151-3/+6
| | | | | non-POSIX basename semantics. ok millert@
* If we are asked to print the total number of blocks, do so even ifmillert2020-10-072-17/+22
| | | | | | | 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@
* I observed "csh i < file-containing-^T" to hit tenex(), which proceeds toderaadt2020-10-061-8/+15
| | | | | | | | 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
* -f - can respresent both stdin and stdout; rework the text a littlejmc2020-10-051-7/+8
| | | | | | | to make it read better; reported by roderick ok millert
* Use ferror() to check for write error, not the fflush() return value.millert2020-10-031-2/+3
| | | | | We can't rely on buffering to catch write errors in fflush(). Based on a diff from Demi M. Obenour, OK kn@
* Clear screen before redrawing the line with ^L, also in input mode.millert2020-09-202-29/+62
| | | | | | 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@
* Fix "$@" splitting with empty IFStb2020-09-131-17/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix multiple variable definitions to avoid errors with -fno-common.mortimer2020-08-306-88/+174
| | | | ok millert@
* clang10 identifies an argv[] comparison against '\0' instead of NULL,deraadt2020-08-031-2/+2
| | | | | it results in the same, but is incorrect. ok millert
* Collapse consecutive stars to avoid exponential behavior.millert2020-07-221-1/+4
| | | | OK tb@
* Clarify that csh's -f flag is not just about .cshrc.millert2020-07-081-6/+4
| | | | | We don't need to be too specific about this in su(1), leave the details for csh(1). OK jca@
* Add support for set -o pipefailjca2020-07-074-7/+41
| | | | | | | | | | | | | | | | 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@
* Always print the directory name in -R mode; matches historical behavior.millert2020-07-061-2/+2
| | | | | | 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@
* Fix skipping of directories that begin with a '.' in -R mode.millert2020-07-061-2/+4
| | | | | | | 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@
* Fix the exit code when eval()uating a || compound list, it wouldbenno2020-05-221-1/+7
| | | | | | | 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@
* Change install images called *.fs to *.img. These are UFS filesystem images,deraadt2020-05-171-3/+3
| | | | | | | | 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
* Use proper function pointer type instead of void *jca2020-05-081-5/+7
| | | | | | | | | | 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@
* in case we can't create intermediate directories because of permissions,espie2020-03-232-7/+9
| | | | | | show a less confusing track okay millert@ (with a small tweak to the error message by millert@)
* sleep(1): style(9) and other dustingcheloha2020-02-251-20/+17
| | | | | | | | | | | | | | | | | | - 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.
* Enforce that TMOUT is an integer literal to prevent command execution fromtb2020-02-211-1/+5
| | | | | | | | | | | 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
* get rid of an awkward ellipsis noticed by Jan Stary; OK jmc@schwarze2020-02-141-5/+5
|
* Do not mark up punctuation (equal signs), get rid of needless .Xo and .Sm,schwarze2020-02-141-28/+18
| | | | | | 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@.
* briefly mention /etc/examples/ in the FILES section of all theschwarze2020-02-101-3/+5
| | | | | manual pages that document the corresponding configuration files; OK jmc@, and general direction discussed with many
* drop historical section number as was done in psjsg2020-02-091-4/+3
|
* Make HISTORY more concise: historical section numbers are irrelevant.schwarze2020-02-081-5/+4
| | | | Fluff noticed by jsg@.
* Usually, -width Fl (which is 10n) is too wide and hence ugly.schwarze2020-01-165-22/+22
| | | | Change several instances, most of them to the usual -width Ds.
* Rev 1.17 of sub.c removed infinite loop detection from s command.bluhm2020-01-094-4/+3
| | | | | Adapt substitute test to new ed(1) behavior. Note that substitute result from sed(1) is still different.
* Rev 1.59 of main.c allows omission of addresses in a range.bluhm2020-01-0919-1/+53
| | | | Adapt ed test.
* Rev 1.42 of main.c allows zero address for i command.bluhm2020-01-093-0/+3
| | | | Adapt ed test.
* Delete tests for P_THREAD that predate the existence ofguenther2019-12-161-3/+1
| | | | | | | | 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@
* typo fix.nayden2019-11-291-2/+2
| | | | ok deraadt@
* some corrections to CDPATH;jmc2019-11-261-4/+6
| | | | from chohag
* In cpio mode, when processing the -o switch, only set the archive formatnaddy2019-11-151-2/+3
| | | | | if not already set. This makes "cpio -Hustar -o" behave the same as "cpio -o -Hustar". ok guenther@
* No need for <sys/uio.h> as writev(2) isn't used any more.jca2019-10-271-2/+1
|
* Don't fail hard if we can't preallocate history storage.jca2019-10-271-7/+15
| | | | | | | | | | | 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.
* More Version 1 AT&T UNIX history.schwarze2019-09-061-2/+7
| | | | | | 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>.