summaryrefslogtreecommitdiffstats
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* test(1): Fix markup, ( and ) must be separate arguments so leave spaces.jilles2010-09-101-1/+1
| | | | MFC after: 1 week
* test(1): Clarify grammar ambiguity and -a/-o vs shell &&/||.jilles2010-09-101-5/+12
|
* sh(1): Remove xrefs for expr(1) and getopt(1).jilles2010-09-101-3/+1
| | | | | | | | | | | expr(1) should usually not be used as various forms of parameter expansion and arithmetic expansion replicate most of its functionality in an easier way. getopt(1) should not be used at all in new code. Instead, getopts(1) or entirely manual parsing should be used. MFC after: 1 week
* expr(1): Add sh(1) versions of examples, remove an incorrect example.jilles2010-09-091-10/+21
| | | | | | | | | | The three examples are better done using sh(1) itself these days. The example expr -- "$a" : ".*" is incorrect in the general case, as "$a" may be an operator. MFC after: 2 weeks
* sh: Fix 'read' if all chars before the first IFS char are backslash-escaped.jilles2010-09-081-0/+1
| | | | | | Backslash-escaped characters did not set the flag for a non-IFS character. MFC after: 2 weeks
* sh: Improve comments in expand.c.jilles2010-09-051-21/+37
|
* sh: Get rid of some magic numbers.jilles2010-09-041-2/+2
| | | | MFC after: 1 week
* sh: Do not use locale for determining if something is a name.jilles2010-09-031-5/+5
| | | | | | | | | | | This makes it impossible to use locale-specific characters in variable names. Names containing locale-specific characters make scripts only work with the correct locale setting. Also, they did not even work in many practical cases because multibyte character sets such as utf-8 are not supported. This also avoids weirdness if LC_CTYPE is changed in the middle of a script.
* Touch the man page date after updating the ustar limitations.brian2010-08-291-1/+1
| | | | MFC after: 3 weeks
* Correct an out-by-one error when earlying out ustar filenames thatbrian2010-08-292-2/+4
| | | | | | | | | | | | | are too long. Filenames escaping this test are caught later on, so the bug doesn't cause any breakage. Document the correct ustar limitations in pax. As I have no access to the IEEE 1003.2 spec, I can only assume that the limitations imposed are in fact correct. Add regression tests for the filename limitations imposed by pax. MFC after: 3 weeks
* Fix incorrect usage of 'assure' and 'insure'.brucec2010-08-281-1/+1
| | | | Approved by: rrs (mentor)
* Fix an off-by-one error where we try to split a path name that'sbrian2010-08-271-1/+1
| | | | | | | more than 100 characters long and the 101th last character is a '/'. MFC after: 3 weeks
* sh: Remove remnants of '!!' to negate pattern.jilles2010-08-221-17/+2
| | | | | | | | This Almquist extension was disabled long ago. In pathname generation, components starting with '!!' were treated as containing wildcards, causing unnecessary readdir (which could fail, causing pathname generation to fail while it should not).
* sh(1): Add a brief summary of arithmetic expressions.jilles2010-08-221-5/+36
|
* sh: Fix break/continue/return sometimes not skipping the rest of dot script.jilles2010-08-151-2/+3
| | | | | | | | | | | | | In our implementation and most others, a break or continue in a dot script can break or continue a loop outside the dot script. This should cause all further commands in the dot script to be skipped. However, cmdloop() did not know about this and continued to parse and execute commands from the dot script. As described in the man page, a return in a dot script in a function returns from the function, not only from the dot script. There was a similar issue as with break and continue. In various other shells, the return appears to return from the dot script, but POSIX seems not very clear about this.
* sh: Add a forgotten const.jilles2010-08-131-1/+1
|
* sh: Fix shadowing of sigset.jilles2010-08-131-3/+3
|
* sh: Fix heap-based buffer overflow in pathname generation.jilles2010-08-101-16/+15
| | | | | | | | | | | | | | The buffer for generated pathnames could be too small in some cases. It happened to be always at least PATH_MAX long, so there was never an overflow if the resulting pathnames would be usable. This bug may be abused if a script subjects input from an untrusted source to pathname generation, which a bad idea anyhow. Most shell scripts do not work on untrusted data. secteam@ says no advisory is necessary. PR: bin/148733 Reported by: Changming Sun snnn119 at gmail com MFC after: 10 days
* Remove unnecessary duplicate letters in mksyntax.c,jilles2010-08-081-2/+2
| | | | the table elements would just be overwritten twice.
* sh: Return 0 from eval if no command was given.jilles2010-08-031-1/+7
| | | | | | | | | | | This makes a difference if there is a command substitution. To make this work, evalstring() has been changed to set exitstatus to 0 if no command was executed (the string contained only whitespace). Example: eval $(false); echo $? should print 0.
* Document the new argument parser for sleep(1) and SIGINFO behaviour.kib2010-08-021-6/+7
| | | | | | Remove higlight for the unportability notice. MFC after: 3 weeks
* Simplify argument parser by using sscanf(); simplify usage() by notkib2010-08-021-72/+19
| | | | | | | | | | refusing to use stdio. Reduce nesting level in the sleep loop by returning earlier for negative timeouts. Limit the maximum timeout to INT_MAX seconds. Submitted by: bde MFC after: 3 weeks
* sh: Do not enter consecutive duplicates into the history.jilles2010-08-011-0/+1
| | | | | | | | | | | | This simply sets a flag in libedit. It has a shortcoming in that it does not apply to multi-line commands. Note that a configuration option for this is not going to happen, but always having this seems better than not having it. NetBSD has done the same. PR: bin/54683 Obtained from: NetBSD MFC after: 1 month
* Spelling fixes.joel2010-07-311-1/+1
|
* Deal with proper format for printing time_t.kib2010-07-311-3/+5
| | | | | Reported by: ache MFC after: 3 weeks
* Report the time left for the sleep on SIGINFO.kib2010-07-311-19/+47
| | | | | | | Be stricter in the checking of interval specification. PR: bin/139345 MFC after: 3 weeks
* kill: Stop processing if a syntactically invalid pid is encountered.jilles2010-07-291-4/+3
| | | | | | | | | | | | So a command like kill _HUP 1 now fails without sending SIGTERM to init. The behaviour when kill(2) fails remains unchanged: processing continues. This matches other implementations and POSIX and is useful for killing multiple processes at once when some of them may already be gone. PR: bin/40282
* Typo fix: s/ommited/omittedbcr2010-07-271-2/+2
| | | | MFC after: 4 days
* sh: Fix crash due to uninitialized here-document.jilles2010-07-251-0/+3
| | | | | | | | | | | | | | | If an ; or & token was followed by an EOF token, pending here-documents were left uninitialized. Execution would crash, either in the main shell process for literal here-documents or in a child process for expanded here-documents. In the latter case the problem is hard to detect apart from the core dumps and log messages. Side effect: slightly different retries on inputs where EOF is not persistent. Note that tools/regression/bin/sh/parser/heredoc6.0 still causes a similar crash in a child process. The text passed to eval is malformed and should be rejected.
* Fix alignment for the 'flags' label, and make more room for 'tdev'.trasz2010-07-241-2/+2
| | | | MFC after: 1 month
* Add P_HASTHREADS flag description.trasz2010-07-241-1/+2
|
* sh: Allow a background command consisting solely of redirections.jilles2010-07-181-0/+1
| | | | | | | Example: </dev/null & MFC after: 2 weeks
* sh: There cannot be a TNOT in simplecmd(), remove checks.jilles2010-07-141-19/+3
| | | | | | simplecmd() only handles simple commands and function definitions, neither of which involves the ! keyword. The initial token on entry to simplecmd() is one of the following: TSEMI, TAND, TOR, TNL, TEOF, TWORD, TRP.
* Add -l to the synopsisbrian2010-07-121-1/+1
| | | | | Submitted by: jhell at dataix dot net MFC after: 3 days
* sh: Use $PWD instead of getcwd() for the \w and \W prompt expansions.jilles2010-07-021-12/+11
| | | | | | This ensures that the logical working directory (which may include symlinks) is shown and is similar to the default behaviour of the pwd builtin.
* sh: Forget about terminated background processes sooner.jilles2010-06-294-9/+66
| | | | | | | | | | | | | | | | | | | | | | | | Unless $! has been referenced for a particular job or $! still contains that job's pid, forget about it after it has terminated. If $! has been referenced, remember the job until the wait builtin has reported its completion (either with the pid as parameter or without parameters). In interactive mode, jobs are forgotten after termination has been reported, which happens before primary prompts and through the jobs builtin. Even then, though, remember a job if $! has been referenced. This is similar to what is suggested by POSIX and should fix most memory leaks (which also tend to cause sh to use more CPU time) with long running scripts that start background jobs. Caveats: * Repeatedly referencing $! without ever doing 'wait', like while :; do foo & echo started foo: $!; sleep 60; done will still use a lot of memory and CPU time in the long run. * The jobs and jobid builtins do not cause a job to be remembered for longer like expanding $! does. PR: bin/55346
* Recognise the -l switch with pkill - list kill command(s) used.brian2010-06-202-8/+16
| | | | | | PR: 143558 Submitted by: eitanadlerlist at gmail dot com MFC after: 3 weeks
* sh: Fix compilation with -DNO_HISTORY.jilles2010-06-191-0/+1
| | | | | | | | | | | The LINENO code uses snprintf() and relied on "myhistedit.h" to pull in the necessary <stdio.h>. Compiling with -DNO_HISTORY disables all editing and history support and allows linking without -ledit -ltermcap. This may be useful for embedded systems. MFC after: 2 weeks
* sh: Add filename completion.jilles2010-06-151-0/+4
| | | | | | | | | | | | This uses the new libedit completion function with quoting support. Unlike NetBSD, there is no 'set +o tabcomplete' option to disable completion. I do not see any reason for such a special treatment, as completion is rather useful and it is possible to do bind ^I ed-insert to disable completion and insert a tab character instead. Submitted by: Guy Yur
* More mdoc nitpicking to improve compatibility to mdocmluqs2010-06-111-1/+1
| | | | | | | | - .Nd in section NAME is not optional - .Ed was missing - "indent" is not a flag, but a literal argument for -offset - stop switching font sizes for acronyms - use .Brq instead of rolling our own
* sh: Pass through SIGINT from a child if interactive and job controljilles2010-06-061-0/+6
| | | | | | | | | | | | | | | is enabled. This already worked if without job control. In either case, this depends on it that a process that terminates due to SIGINT exits on it (so not with status 1, or worse, 0). Example: sleep 5; echo continued This does not print "continued" any more if sleep is aborted via ctrl+c. MFC after: 1 month
* Don't try to copy a socket after "xxx is a socket (not copied)." message.trasz2010-06-051-0/+1
| | | | | | | | | Previously, it would either try to copy it anyway and fail (without -R), or create fifo instead of the socket (with -R). Found with: Coverity Prevent CID: 5623 MFC after: 2 weeks
* Explain that setting an absolute day value can fail and that the month shouldbrian2010-06-041-3/+11
| | | | | | | | | | usually be set first when using -v. Adjust an example that sets the day to 30 before setting the month to 3 in accordance with this approach as the example would always fail in February! PR: 147354 MFC after: 2 weeks
* sh: Pass TERM changes to libedit.jilles2010-06-024-0/+22
| | | | | | | | I have changed the patch slightly to ignore TERM changes in subshells. PR: bin/146916 Submitted by: Guy Yur Obtained from: NetBSD
* Zero struct before reading from ituqs2010-06-021-0/+1
| | | | | | PR: 140384 Found by: clang static analyzer MFC after: 3 weeks
* sh: Fix a crash if a heredoc was not properly ended and parsing continued.jilles2010-05-301-0/+1
| | | | | | | | | Example (in interactive mode): cat <<EOF && ) The next command typed caused sh to segfault, because the state for the here document was not reset. Like parser_temp, this uses the fact that the parser is not re-entered.
* sh: Change interaction of command substitution and here documents.jilles2010-05-301-4/+13
| | | | | | | | | | | | | | | | | If a command substitution contains a newline token, this no longer starts here documents of outer commands. This way, we follow POSIX's idea of the command substitution being a separate script more closely. It also matches other shells better and is consistent with newline characters in quotes not starting here documents. The extension tested in parser/heredoc3.0 ($(cat <<EOF)\ntext\nEOF\n) continues to be supported. In particular, this change allows things like cat <<EOF && echo `pwd` (a `` command substitution after a here document) which formerly silently used an empty file as the here document, because the EOF of the inner command "pwd" also forced an empty here document.
* sh: Recognize "--" in . and exec.jilles2010-05-282-2/+14
| | | | | | | | | | | | | | | | | | Although "--" historically has not been required to be recognized for certain special builtins that do not take options in POSIX, some other implementations recognize options for them, requiring scripts to use "--" or avoid operands starting with "-". Operands starting with "-" can be avoided with eval by prepending a space, and cannot occur with break, continue, exit, return and shift as they only take numbers, nor with times as it does not take operands. With . and exec, avoiding "-" is not so easy as it may require reimplementing the PATH search; therefore the current proposal for POSIX is to require recognition of "--" for them. We continue to accept other strings starting with "-" as operands to . and exec, and also "--" if it is alone to . (which would otherwise be invalid anyway).
* sh(1): Rework documentation of shell variables.jilles2010-05-241-87/+118
| | | | | | | | | * Move the "environment variables" that do not need exporting to be effective or that are set by the shell without exporting to a new section "Special Variables". * Add special variables LINENO and PPID. * Add environment variables LANG, LC_* and PWD; also describe ENV under environment variables.
* sh(1): Improve wording of 'Special Parameters' section.jilles2010-05-241-7/+3
|
OpenPOWER on IntegriCloud