summaryrefslogtreecommitdiffstats
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* Language cleanup.des2010-10-271-3/+3
|
* sh: Ignore double-quotes in arithmetic rather than treating them as quotes.jilles2010-10-242-5/+5
| | | | | | | | This provides similar behaviour, but allows a simpler parser. This changes r206473. Exp-run done by: pav (with some other sh(1) changes)
* sh: Do not allow overriding a special builtin with a function.jilles2010-10-241-0/+5
| | | | | | | | | | | | | | | | | This is a syntax error. POSIX does not say explicitly whether defining a function with the same name as a special builtin is allowed, but it does say that it is impossible to call such a function. A special builtin can still be overridden with an alias. This commit is part of a set of changes that will ensure that when something looks like a special builtin to the parser, it is one. (Not the other way around, as it remains possible to call a special builtin named by a variable or other substitution.) Exp-run done by: pav (with some other sh(1) changes)
* sh: Make sure defined functions can actually be called.jilles2010-10-241-3/+7
| | | | | | | | | | | | | | | | | Add some conservative checks on function names: - Disallow expansions or quoting characters; these can only be called via strange control characters - Disallow '/'; these functions cannot be called anyway, as exec.c assumes they are pathnames - Make the CTL* bytes work properly in function names. These are syntax errors. POSIX does not require us to support more than names (letters, digits and underscores, not starting with a digit), but I do not want to restrict it that much at this time. Exp-run done by: pav (with some other sh(1) changes)
* sh: Check whether dup2 was successful for >&FD and <&FD.jilles2010-10-241-2/+5
| | | | | | A failure (usually caused by FD not being open) is a redirection error. Exp-run done by: pav (with some other sh(1) changes)
* sh: Change ! within a pipeline to start a new pipeline instead.jilles2010-10-241-19/+11
| | | | | | | | | | | | | | This is how ksh93 treats ! within a pipeline and makes the ! in a | ! b | c negate the exit status of the pipeline, as if it were a | { ! b | c; } Side effect: something like f() ! a is now a syntax error, because a function definition takes a command, not a pipeline. Exp-run done by: pav (with some other sh(1) changes)
* sh(1): Clarify subshells/processes for pipelines.jilles2010-10-161-10/+8
| | | | | | | | | For multi-command pipelines, 1. all commands are direct children of the shell (unlike the original Bourne shell) 2. all commands are executed in a subshell (unlike the real Korn shell) MFC after: 1 week
* sh: Use <stddef.h> rather than <sys/stddef.h>.jilles2010-10-161-1/+1
| | | | <sys/stddef.h> is only for the kernel and conflicts with <stddef.h>.
* We only need to look as far as '..' to find 'test/'.obrien2010-10-131-1/+1
|
* Do not assume in growstackstr() that a "precious" character will beobrien2010-10-133-9/+19
| | | | | | | | | | | | | | | | immediately written into the stack after the call. Instead let the caller manage the "space left". Previously, growstackstr()'s assumption causes problems with STACKSTRNUL() where we want to be able to turn a stack into a C string, and later pretend the NUL is not there. This fixes a bug in STACKSTRNUL() (that grew the stack) where: 1. STADJUST() called after a STACKSTRNUL() results in an improper adjust. This can be seen in ${var%pattern} and ${var%%pattern} evaluation. 2. Memory leak in STPUTC() called after a STACKSTRNUL(). Reviewed by: jilles
* In the spirit of r90111, depend on c89 and remove the "STATIC" macroobrien2010-10-1321-227/+218
| | | | and its usage.
* If one wishes to set breakpoints of static the functions here, theyobrien2010-10-131-1/+1
| | | | | | cannot be inlined. Submitted by: jhb
* Make DEBUG traces 64-bit clean:jhb2010-10-132-20/+21
| | | | | | | | | - Use %t to print ptrdiff_t values. - Cast a ptrdiff_t value explicitly to int for a field width specifier. While here, sort includes. Submitted by: Garrett Cooper
* Suggest that DEBUG_FLAGS be used to enable extra debugging rather thanjhb2010-10-131-1/+1
| | | | | | | frobbing CFLAGS directly. DEBUG_FLAGS is something that can be specified on the make command line without having to edit the Makefile directly. Submitted by: Garrett Cooper
* Consistently use "STATIC" for all functions in order to be able to setobrien2010-10-1317-73/+77
| | | | | | breakpoints with in a debugger. And use naked "static" for variables. Noticed by: bde
* If DEBUG is 3 or greater, disable STATICization of functions.obrien2010-10-123-3/+8
| | | | Also correct the documented location of the trace file.
* Allow one to regression test 'sh' changes without having to installobrien2010-10-121-0/+3
| | | | a potentially bad /bin/sh first.
* rm(1): clarify that -P works only when blocks are updated in-placeuqs2010-10-082-6/+6
| | | | Suggested by: pjd, ivoras, arundel
* mdoc: drop redundant .Pp and .LP callsuqs2010-10-082-2/+0
| | | | They have no effect when coming in pairs, or before .Bl/.Bd
* Make a thread's address available via the kern proc sysctl, just like theemaste2010-10-082-0/+4
| | | | | | | | process address. Add "tdaddr" keyword to ps(1) to display this thread address. Distilled from Sandvine's patch set by Mark Johnston.
* Clarify the combination effect of -P and -f to make it clear.delphij2010-10-041-3/+7
| | | | | Submitted by: arundel MFC after: 2 weeks
* Correct sort order.emaste2010-09-221-1/+1
|
* Merge from tbemd:imp2010-09-131-6/+7
| | | | | | Add directory names directly and sort at the end. Include bsd.arch.inc.mk so we can, in the future, more easily make arch dependent changes in /bin (unlikely, but is needed for symmetry).
* sh: Add __dead2 to two functions that do not return.jilles2010-09-121-2/+2
| | | | | Apart from helping static analyzers, this also appears to reduce the size of the binary slightly.
* sh: Fix exit status if return is used within a loop condition.jilles2010-09-111-0/+2
|
* sh: Apply variable assignments left-to-right in bltinlookup().jilles2010-09-111-1/+5
| | | | | Example: HOME=foo HOME=bar cd
* Revert changes of 'assure' to 'ensure' made in r211936.brucec2010-09-111-1/+1
| | | | Approved by: rrs (mentor)
* 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
OpenPOWER on IntegriCloud