summaryrefslogtreecommitdiffstats
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* 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
* sh: Fix two things about {(...)} <redir:jilles2011-02-051-1/+4
| | | | | | | | * In {(...) <redir1;} <redir2, do not drop redir1. * Maintain the difference between (...) <redir and {(...)} <redir: In (...) <redir, the redirection is performed in the child, while in {(...)} <redir it should be performed in the parent (like {(...); :;} <redir)
* sh: Remove clearcmdentry()'s now unused argument.jilles2011-02-053-11/+10
|
* sh: Forget all cached command locations on any PATH change.jilles2011-02-051-24/+1
| | | | | | | | | POSIX requires this and it is simpler than the previous code that remembered command locations when appending directories to PATH. In particular, PATH=$PATH is no longer a no-op but discards all cached command locations.
* sh: Do not try to execute binary files as scripts.jilles2011-02-052-1/+16
| | | | | | | | | | If execve() returns an [ENOEXEC] error, check if the file is binary before trying to execute it using sh. A file is considered binary if at least one of the first 256 bytes is '\0'. In particular, trying to execute ELF binaries for the wrong architecture now fails with an "Exec format error" message instead of syntax errors and potentially strange results.
* sh: Remove special code for shell scripts without magic number.jilles2011-02-0417-224/+27
| | | | | | | | | | These are called "shell procedures" in the source. If execve() failed with [ENOEXEC], the shell would reinitialize itself and execute the program as a script. This requires a fair amount of code which is not frequently used (most scripts have a #! magic number). Therefore just execute a new instance of sh (_PATH_BSHELL) to run the script.
* Make sys_signame upper case.jilles2011-02-043-5/+5
| | | | | | | | | | | | This matches the constants from <signal.h> with 'SIG' removed, which POSIX requires kill and trap to accept and 'kill -l' to write. 'kill -l', 'trap', 'trap -l' output is now upper case. In Turkish locales, signal names with an upper case 'I' are now accepted, while signal names with a lower case 'i' are no longer accepted, and the output of 'killall -l' now contains proper capital 'I' without dot instead of a dotted capital 'I'.
* sh: Return only 126 or 127 for execve() failures.jilles2011-02-031-12/+5
| | | | Do not return 2 for errors other than [EACCES] or [ENOENT].
* sh: Remove comment mentioning herefd, which is gone.jilles2011-02-021-2/+1
|
* sh: Send messages about signals to stderr.jilles2011-01-301-5/+5
| | | | | | This is required by POSIX and seems to make more sense. See also r217557.
* sh: Clean up some old comments:jilles2011-01-251-6/+3
| | | | | | | | | * There is no plan for an alternative to the command "set". * Attempting to unset a readonly variable has not raised an error for quite a while, so the order of unsetting a variable and a function with the same name does not matter. MFC after: 1 week
* Document P_FOLLOWFORK.kib2011-01-251-0/+1
| | | | MFC after: 2 weeks
OpenPOWER on IntegriCloud