summaryrefslogtreecommitdiffstats
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix some typos under bin/uqs2011-05-223-4/+4
| | | | Found by: codespell
* Fix a bunch of typos and a couple of whitespace nits.uqs2011-05-2212-47/+47
| | | | Helped by: codespell and vim's spellchecker
* sh: Fix bss-based buffer overflow in . builtin.jilles2011-05-221-4/+7
| | | | | | | | | | | If the length of a directory in PATH together with the given filename exceeded FILENAME_MAX (which may happen even for pathnames that work), a static buffer was overflown. The static buffer is unnecessary, we can use the stalloc() stack. Obtained from: NetBSD MFC after: 1 week
* sh: Expand aliases after assignments and redirections.jilles2011-05-214-12/+29
|
* sh: Implement the cd -e flag proposed for the next POSIX issue.jilles2011-05-202-10/+28
| | | | | | | | | This reflects failure to determine the pathname of the new directory in the exit status (1). Normally, cd returns successfully if it did chdir() and the call was successful. In POSIX, -e only has meaning with -P; because our -L is not entirely compliant and may fall back to -P mode, -e has some effect with -L as well.
* sh: Allow terminating a heredoc with a terminator at EOF without a newline.jilles2011-05-201-3/+5
| | | | | | | | | | | | | | | | | | | | | | This is sometimes used with eval or old-style command substitution, and most shells other than ash derivatives allow it. It can also be used with scripts that violate POSIX's requirement on the application that they end in a newline (scripts must be text files except that line length is unlimited). Example: v=`cat <<EOF foo EOF` echo $v This commit does not add support for the similar construct with new-style command substitution, like v=$(cat <<EOF foo EOF) This continues to require a newline after the terminator.
* Spelling in P_HADTHREADS.pluknet2011-05-201-1/+1
| | | | MFC after: 1 week
* Fix the description of the "paddr" keyword. It shows a processpluknet2011-05-201-1/+1
| | | | | | pointer just like a dublicating "uprocp". MFC after: 1 week
* sh: Minor optimization to output from ulimit/export/readonly.jilles2011-05-152-8/+7
| | | | No functional change is intended.
* sh: Avoid close(-1) when evaluating a multi-command pipeline.jilles2011-05-151-1/+2
| | | | Valgrind complains about this.
* Update sticky(7) cross references.pluknet2011-05-132-7/+7
| | | | | PR: docs/124468 X-MFC with: r218998
* sh: Add \u/\U support (in $'...') for UTF-8.jilles2011-05-085-4/+37
| | | | | | | | | | Because we have no iconv in base, support for other charsets is not possible. Note that \u/\U are processed using the locale that was active when the shell started. This is necessary to avoid behaviour that depends on the parse/execute split (for example when placing braces around an entire script). Therefore, UTF-8 encoding is implemented manually.
* sh: Optimize variable code by storing the length of the name.jilles2011-05-082-124/+125
| | | | Obtained from: NetBSD
* sh(1): Update BUGS section for UTF-8 support.jilles2011-05-081-2/+7
|
* sh: Add UTF-8 support to pattern matching.jilles2011-05-081-12/+50
| | | | | | | | | | ?, [...] patterns match codepoints instead of bytes. They do not match invalid sequences. [...] patterns must not contain invalid sequences otherwise they will not match anything. This is so that ${var#?} removes the first codepoint, not the first byte, without putting UTF-8 knowledge into the ${var#pattern} code. However, * continues to match any string and an invalid sequence matches an identical invalid sequence. (This differs from fnmatch(3).)
* sh: Add UTF-8 support to ${#var}.jilles2011-05-071-3/+13
| | | | | If the current locale uses UTF-8, ${#var} counts codepoints (more precisely, bytes b with (b & 0xc0) != 0x80).
* sh: Track if the current locale's charset is UTF-8 or not.jilles2011-05-063-0/+24
|
* sh: Change the CTL* bytes to ones invalid in UTF-8.jilles2011-05-061-8/+8
| | | | | | | | | | | | | This ensures that mbrtowc(3) can be used directly once it has been verified that there is no CTL* byte. Dealing with a CTLESC byte within a multibyte character would be complicated. The new values do occur in iso-8859-* encodings. This decreases efficiency slightly but should not affect correctness. Caveat: Updating across this change and rebuilding without cleaning may yield a subtly broken sh binary. By default, make buildworld will clean and avoid problems.
* sh: Add $'quoting' (C-style escape sequences).jilles2011-05-053-8/+212
| | | | | | | | | | | | | | | | | | | | | | | | A string between $' and ' may contain backslash escape sequences similar to the ones in a C string constant (except that a single-quote must be escaped and a double-quote need not be). Details are in the sh(1) man page. This construct is useful to include unprintable characters, tabs and newlines in strings; while this can be done with a command substitution containing a printf command, that needs ugly workarounds if the result is to end with a newline as command substitution removes all trailing newlines. The construct may also be useful in future to describe unprintable characters without needing to write those characters themselves in 'set -x', 'export -p' and the like. The implementation attempts to comply to the proposal for the next issue of the POSIX specification. Because this construct is not in POSIX.1-2008, using it in scripts intended to be portable is unwise. Matching the minimal locale support in the rest of sh, the \u and \U sequences are currently not useful. Exp-run done by: pav (with some other sh(1) changes)
* sh: Apply set -u to variables in arithmetic.jilles2011-05-041-0/+2
| | | | | | | Note that this only applies to variables that are actually used. Things like (0 && unsetvar) do not cause an error. Exp-run done by: pav (with some other sh(1) changes)
* sh: Detect an error for ${#var<GARBAGE>}.jilles2011-05-041-0/+2
| | | | | | | | | In particular, this makes things like ${#foo[0]} and ${#foo[@]} errors rather than silent equivalents of ${#foo}. PR: bin/151720 Submitted by: Mark Johnston Exp-run done by: pav (with some other sh(1) changes)
* Don't call -f option's argument "stdin".ru2011-05-031-1/+4
| | | | MFC after: 3 days
* sh: Set $? to 0 for background commands.jilles2011-04-251-3/+6
| | | | | | | | | | For backgrounded pipelines and subshells, the previous value of $? was being preserved, which is incorrect. For backgrounded simple commands containing a command substitution, the status of the last command substitution was returned instead of 0. If fork() fails, this is an error.
* sh: Check setuid()/setgid() return values.jilles2011-04-251-2/+4
| | | | | | | | | | | | If the -p option is turned off, privileges from a setuid or setgid binary are dropped. Make sure to check if this succeeds. If it fails, this is an error which will cause the shell to abort except in interactive mode or if 'command' was used to make 'set' or an outer 'eval' or '.' non-special. Note that taking advantage of this feature and writing setuid shell scripts seems unwise. MFC after: 1 week
* sh: Remove duplicate code resetting uid/gid for set +p/+o privileged.jilles2011-04-251-10/+5
| | | | MFC after: 1 week
* sh: Allow EV_EXIT through function calls, make {...} <redir more consistent.jilles2011-04-233-13/+16
| | | | | | | | | | | | | | | | | | | | | If EV_EXIT causes an exit, use the exception mechanism to unwind redirections and local variables. This way, if the final command is a redirected command, an EXIT trap now executes without the redirections. Because of these changes, EV_EXIT can now be inherited by the body of a function, so do so. This means that a function no longer prevents a fork before an exec being skipped, such as in f() { head -1 /etc/passwd; }; echo $(f) Wrapping a single builtin in a function may still cause an otherwise unnecessary fork with command substitution, however. An exit command or -e failure still invokes the EXIT trap with the original redirections and local variables in place. Note: this depends on SHELLPROC being gone. A SHELLPROC depended on keeping the redirections and local variables and only cleaning up the state to restore them.
* sh: Do not word split "${#parameter}".jilles2011-04-201-2/+2
| | | | | | | | | | | | | This is only a problem if IFS contains digits, which is unusual but valid. Because of an incorrect fix for PR bin/12137, "${#parameter}" was treated as ${#parameter}. The underlying problem was that "${#parameter}" erroneously added CTLESC bytes before determining the length. This was properly fixed for PR bin/56147 but the incorrect fix was not backed out. Reported by: Seeker on forums.freebsd.org MFC after: 2 weeks
* Document problems with -d/-w and the fact that -X is the default.trasz2011-04-181-2/+9
| | | | | Suggested by: arundel@ Reviewed by: arundel@
* Get rid of DSIZ; instead just call the sizing function if provided.trasz2011-04-123-16/+15
|
* Make it possible to use permission sets (full_set, modify_set, read_settrasz2011-04-091-2/+17
| | | | | | | | and write_set) with setfacl(1). PR: kern/154113 Submitted by: Shawn Webb <lattera at gmail dot com> (earlier version) MFC after: 1 month
* Add proper width calculation for time fields (time, cputime and usertime).trasz2011-03-243-5/+52
| | | | This fixes the ugly overflow in "ps aux" output for "[idle]".
* Make "LOGIN" and "CLASS" columns width scale properly instead of wasting space.trasz2011-03-243-5/+34
|
* sh(1): Describe subshell environment, command substitution more correctly.jilles2011-03-201-7/+19
| | | | | | | | | | | POSIX does not require the shell to fork for a subshell environment, and we use that possibility in various ways (command substitutions with a single command and most subshells that are the final command of a shell process). Therefore do not tie subshells to forking in the man page. Command substitutions with expansions are a bit strange, causing a fork for $(...$(($x))...) because $x might expand to y=2; they will probably be changed later but this is how they work now.
* Implement the usertime and systime keywords for ps, printing thekib2011-03-174-21/+63
| | | | | | | corresponding times reported by getrusage(). Submitted by: Dan Nelson <dnelson allantgroup com> MFC after: 1 week
* bin: Prefer strrchr() to rindex().jilles2011-03-153-3/+3
| | | | This removes the last index/rindex usage from /bin.
* sh: Fix some parameter expansion variants ${#...}.jilles2011-03-131-19/+30
| | | | | | | | | These already worked: $# ${#} ${##} ${#-} ${#?} These now work as well: ${#+word} ${#-word} ${##word} ${#%word} There is an ambiguity in the standard with ${#?}: it could be the length of $? or it could be $# giving an error in the (impossible) case that it is not set. We continue to use the former interpretation as it seems more useful.
* Remove unnecessary cast.stefanf2011-03-071-1/+1
| | | | Reviewed by: jilles
* sh(1): Reduce excessive semicolon-separated sentences.jilles2011-03-061-4/+4
| | | | Reported by: Benjamin Kaduk
* Export login class information via kinfo and make it possible to viewtrasz2011-03-054-1/+28
| | | | it using "ps -o class".
* sh: Fix some warnings in code for arithmetic expressions.jilles2011-03-052-3/+5
| | | | Submitted by: eadler
* kill: Note that this is used both as a normal program and a shell builtin.jilles2011-03-011-0/+4
|
* Accept == as an alias of = which is a popular GNU extension.delphij2011-02-271-0/+1
| | | | | | | This is intentionally undocumented for now since it's not part of any standard. MFC after: 1 month
* When WITH_ICONV is set, use our in-tree iconv.ume2011-02-262-13/+23
|
* mdoc(7) markup.pluknet2011-02-211-1/+1
| | | | | Approved by: avg (mentor), kib (mentor) MFC after: 3 days
* Fix typos - remove duplicate "the".brucec2011-02-212-2/+2
| | | | | | PR: bin/154928 Submitted by: Eitan Adler <lists at eitanadler.com> MFC after: 3 days
* test: Note that this is used both as a normal program and a shell builtin.jilles2011-02-151-0/+4
| | | | MFC after: 1 week
* sh: Detect dividing the smallest integer by -1.jilles2011-02-122-0/+4
| | | | | This overflows and on some architectures such as amd64 it generates SIGFPE. Generate an error on all architectures.
* Fix typos.brucec2011-02-121-2/+2
| | | | | | PR: docs/131625 Submitted by: Andrew Wright <andrew at qemg.org> MFC after: 1 month
* sh(1): Update description of arithmetic.jilles2011-02-081-8/+3
|
* sh: Import arithmetic expression code from dash.jilles2011-02-087-516/+716
| | | | | | | | | | | | | | | | New features: * proper lazy evaluation of || and && * ?: ternary operator * executable is considerably smaller (8K on i386) because lex and yacc are no longer used Differences from dash: * arith_t instead of intmax_t * imaxdiv() not used * unset or null variables default to 0 * let/exp builtin (undocumented, will probably be removed later) Obtained from: dash
OpenPOWER on IntegriCloud