summaryrefslogtreecommitdiffstats
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* sh: Add support for named character classes in bracket expressions.jilles2011-06-152-2/+48
| | | | | Example: case x in [[:alpha:]]) echo yes ;; esac
* Add "gid" and "group" keywords to display the effective group IDtrasz2011-06-144-2/+34
| | | | | | | and effective group name. Also, add "egid", "egroup" and "euid" aliases. PR: bin/146331 Submitted by: Jeremie Le Hen <jeremie at le-hen dot org>
* sh: Fix duplicate prototypes for builtins.jilles2011-06-1323-41/+14
| | | | | | Have mkbuiltins write the prototypes for the *cmd functions to builtins.h instead of builtins.c and include builtins.h in more .c files instead of duplicating prototypes for *cmd functions in other headers.
* sh: Save/restore changed variables in optimized command substitution.jilles2011-06-127-89/+25
| | | | | | | | | | | In optimized command substitution, save and restore any variables changed by expansions (${var=value} and $((var=assigned))), instead of trying to determine if an expansion may cause such changes. If $! is referenced in optimized command substitution, do not cause jobs to be remembered longer. This fixes $(jobs $!) again, simplifies the man page and shortens the code.
* sh: Fix locale-dependent ranges in bracket expressions.jilles2011-06-121-4/+4
| | | | | | | | When I added UTF-8 support in r221646, the LC_COLLATE-based ordering broke because of sign extension of char. Because of libc restrictions, this does not work for UTF-8. For UTF-8 locales, ranges always use character code order.
* sh: Read .profile from the home directory (or / if HOME is not set).jilles2011-06-121-1/+1
| | | | | | | | | | In most cases, login shells are started from the home directory, but not in all, such as xterm -ls. This commit depends on r222957 for read_profile() performing parameter expansion. PR: bin/50569
* sh: Do parameter expansion on ENV before using it.jilles2011-06-102-7/+13
| | | | | | This is required by POSIX, and allows things like ENV=\$HOME/.shrc. Note that tilde expansion is explicitly not performed.
* sh: Do parameter expansion before printing PS4 (set -x).jilles2011-06-095-4/+51
| | | | | | | | | | | | | | | | The function name expandstr() and the general idea of doing this kind of expansion by treating the text as a here document without end marker is from dash. All variants of parameter expansion and arithmetic expansion also work (the latter is not required by POSIX but it does not take extra code and many other shells also allow it). Command substitution is prevented because I think it causes too much code to be re-entered (for example creating an unbounded recursion of trace lines). Unfortunately, our LINENO is somewhat crude, otherwise PS4='$LINENO+ ' would be quite useful.
* sh: Fix $? in heredocs on simple commands.jilles2011-06-051-1/+2
| | | | PR: bin/41410
* sh: Improve error message if the script cannot be opened.jilles2011-06-041-2/+4
| | | | Avoid "<nosuchfile>: cannot open <nosuchfile>: ...".
* sh: Reduce more needless differences between error messages.jilles2011-06-044-5/+5
|
* sh: Honour -n while processing -c string.jilles2011-06-041-1/+1
|
* sh: Remove the "exp" builtin.jilles2011-05-272-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The "exp" builtin is undocumented, non-standard and not very useful. If exp's return value is not used, something like VAR=$(exp EXPRESSION) is equivalent to VAR=$((EXPRESSION)) except that errors in the expression are fatal and quoting special characters is not needed in the latter case. If exp's return value is used, something like if exp EXPRESSION >/dev/null can be replaced by if [ $((EXPRESSION)) -ne 0 ] with similar differences. The exp-run showed that "let" is close enough to bash's and ksh's builtin that removing it would break a few ports. Therefore, "let" remains in 9.x. PR: bin/104432 Exp-run done by: pav (with some other sh(1) changes)
* sh: Correct criterion for using CDPATH in cd.jilles2011-05-271-1/+4
| | | | | | | CDPATH should be ignored not only for pathnames starting with '/' but also for pathnames whose first component is '.' or '..'. The man page already describes this behaviour.
* sh: Various updates to the TOUR document.jilles2011-05-271-29/+8
|
* sh: Fix unquoted $@/$* if IFS=''.jilles2011-05-271-2/+5
| | | | | | If IFS is null, unquoted $@/$* should still expand to separate words. This differs from quoted $@ (which does not depend on IFS) in that pathname generation is performed and empty words are removed.
* sh: Show errno messages in cd.jilles2011-05-251-1/+4
|
* sh: Remove obsolete token type TENDBQUOTE.jilles2011-05-221-1/+0
| | | | | This token type was related to Almquist's original version of backquotes that could not nest and fell into disuse fairly soon.
* 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
|
OpenPOWER on IntegriCloud