summaryrefslogtreecommitdiffstats
path: root/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* Commit the results of the typo hunt by Darren Pilgrim.yar2006-08-041-1/+1
| | | | | | | | | | This change affects documentation and comments only, no real code involved. PR: misc/101245 Submitted by: Darren Pilgrim <darren pilgrim bitfreak org> Tested by: md5(1) MFC after: 1 week
* Do not forget to increment the input line counteryar2006-07-311-0/+1
| | | | | | | when reading a word spanning multiple lines. PR: bin/101094 MFC after: 5 days
* Tell more of the sh(1) history.yar2006-07-291-2/+17
| | | | | | Acknowledge Kenneth Almquist's contribution in AUTHORS. MFC after: 5 days
* Make it easier to find that we have test(1) built-in in sh(1).yar2006-07-261-4/+9
| | | | MFC after: 3 days
* Document the fact that 'true' and 'false' are among sh(1) built-in commands.yar2006-06-211-1/+5
| | | | MFC after: 3 days
* Merge NetBSD's revision 1.86: Don't crash on "<cmd> | { }".stefanf2006-06-151-1/+1
|
* Implement the PS4 variable which is defined by the POSIX User Portabilitystefanf2006-06-154-6/+23
| | | | | | | | | | | | Utilities option. Its value is printed at the beginning of the line if tracing (-x) is active. PS4 defaults to the string "+ " which is compatible with the old behaviour to always print "+ ". We still need to expand variables in PS1, PS2 and PS4. PR: 46441 (part of) Submitted by: schweikh Obtained from: NetBSD
* Don't strip a leading ./ from the path for the cd builtin to avoid interpretingstefanf2006-06-121-2/+3
| | | | | | | | | | .//dir as /dir. Rather strip it only for the purpose of checking if the directory path should be printed. PR: 88813 Submitted by: Josh Elsasser Patch from: NetBSD (cd.c rev 1.38) MFC after: 2 weeks
* POSIX demands that set's output (when invoked without arguments) should bestefanf2006-04-291-9/+47
| | | | | | sorted. Sort the variables before printing. PR: 96415
* Check the buffer size when copying the line returned by el_gets() into ourstefanf2006-04-291-4/+13
| | | | | | | | | own buffer. Interactively typing in long lines (>1023 characters) previously overflowed the buffer. Unlike the NetBSD people I don't see the need to subtract 8 from BUFSIZ, so I just used BUFSIZ-1. Obtained from: NetBSD PR: 91110
* Whitespace nits.schweikh2006-04-172-5/+5
|
* Correct assorted grammos and typos.schweikh2006-04-161-11/+11
|
* Output something reasonable for regular and expanded here-documents.schweikh2006-04-141-0/+6
| | | | | | I would have chosen the EOF markers, but they are no longer available AFAICS, so output "<<HERE" and "<<XHERE" instead. (NOTE: These changes only affect DEBUG output.)
* Implement some of the differences between special built-ins and other builtinsstefanf2006-04-094-19/+23
| | | | | | | | | | | | | | | | | | | | demanded by POSIX. - A redirection error is only fatal (meaning the execution of a shell script is terminated) for special built-ins. Previously it was fatal for all shell builtins, causing problems like the one reported in PR 88845. - Variable assignments remain in effect for special built-ins. - Option or operand errors are only fatal for special built-ins. This change also makes errors from 'fc' non-fatal (I could not find any reasons for this behaviour). Somewhat independently from the above down-grade the error handling in the shift built-in if the operand is bigger than $# from an error() call (which is now fatal) to a return 1. I'm not sure if this should be considered a POSIX "operand error", however this change is needed for now as we trigger that error while building libncurses. Comparing with other shells, zsh does the same as our sh before this change (write a diagnostic, return 1), bash behaves as our sh after this commit (no diagnostic, return 1) and ksh93 and NetBSD's sh treat it as a fatal error.
* Issue an error when . (dot) is invoked without a filename. The synopsisstefanf2006-04-021-8/+10
| | | | | | | is just ". file" according to POSIX, however many other shells allow arguments to be passed after the file. For compatibility (we even use that feature in buildworld) additional arguments are not considered to be an error, even though this shell does not do anything with the arguments at all.
* Use -s to flag POSIX's "special built-in" utilities in builtins.def. Add astefanf2006-04-022-22/+30
| | | | | | | | new member to struct builtincmd and set it to 1 if -s was specified. This is done because there are cases where special builtins must be treated differently from other builtins. Obtained from: NetBSD (builtins.def part)
* Initialize PWD early on (don't expect it to be inherited from theschweikh2006-02-041-0/+2
| | | | | | environment or set it only when changing directories with cd). PR: standards/92640
* s/staticly/statically/gschweikh2006-02-041-2/+2
|
* s/varable/variable/; s/tored/stored/schweikh2006-02-041-2/+2
|
* Remove some white space at EOL.schweikh2006-02-045-15/+15
|
* Document that '#' starts a comment.stefanf2006-01-011-0/+7
| | | | | | | PR: 85103 Submitted by: garys Obtained from: pdksh manual Patch from: Daniel Gerzo (with changes by me)
* o Now when SIG_IGN signal action for SIGCHLD reap zombiesmaxim2005-12-141-0/+2
| | | | | | | | | | | | automatically it is possible wait4(2) returns -1 and sets errno = ECHILD if there were forked children. A user can set such signal handler e.g. via ``trap "" 20'', see a PR for the test case. Deal with this case and mark a job as JOBDONE. PR: bin/90334 Submitted by: bde MFC after: 4 weeks
* - Document trap's -l option and the behaviour of a missing action or a singlestefanf2005-12-081-2/+14
| | | | | | | | dash. - Discourage the omission of the action. PR: 70985 [1] Submitted by: Martin Kammerhofer
* Print empty quotes ('') when an empty string is passed to outqstr().stefanf2005-12-081-0/+4
| | | | | | | This makes a difference for the trap builtin, where after "trap '' 0" we printed "trap -- quit". This is wrong, because an empty action means to reset the action to the default. A side effect of this commit is that empty variables are now printed as "variable=''" instead of just "variable=".
* Correctly quote the output when showing the installed trap actions.stefanf2005-12-081-6/+5
| | | | | PR: 74043 Submitted by: Jilles Tjoelker
* Clarify that the echo builtin takes an arbitrary number of strings.stefanf2005-12-081-4/+3
| | | | Mention that spaces are printed between the strings.
* Sort.stefanf2005-12-041-6/+6
|
* Remove a few commented out builtins from the original ash. The filesstefanf2005-12-041-5/+0
| | | | implementing them were never part of FreeBSD.
* Add the times builtin. It reports the user and system time for the shellstefanf2005-12-044-1/+34
| | | | | | itself and its children. Instead of calling times() (as implied by POSIX) this implementation directly calls getrusage() to get the times because this is more convenient.
* -mdoc sweep.ru2005-11-171-16/+14
|
* Add `local' and `return' to the list of built-ins.jcamou2005-11-031-0/+8
| | | | | Submitted by: garys Approved by: trhodes (mentor)
* Include disabled options in the output of 'set +o'. POSIX says the output ofstefanf2005-10-291-11/+8
| | | | | | | | | | | | set +o can be used to reload previous settings, for this to work disabled options must be printed as well or otherwise options that were set in the mean time won't be turned off. To avoid an excessively long output line I formatted the output to print only six options per line. Submitted by: Jilles Tjoelker PR: 73500
* Document command -v and -V.stefanf2005-10-291-2/+39
| | | | Glanced at by: simon
* Document that read -t timeout returns 1 if the timeout elapses.stefanf2005-10-291-1/+1
|
* Add the POSIX options -v and -V to the 'command' builtin. Both describe thestefanf2005-10-283-13/+67
| | | | | | | type of their argument, if it is a shell function, an alias, a builtin, etc. -V is more verbose than -v. PR: 77259, 84539
* Protect malloc, realloc and free calls with INT{ON,OFF} directly in chkalloc,stefanf2005-10-283-4/+19
| | | | | | | | | | | | | | ckrealloc and ckfree (added), respectively. sh jumps out of the signal handler using longjmp which is obviously a bad idea during malloc calls. Note: I think there is still a small race here because volatile sig_atomic_t only guarantees atomic reads and writes while we're doing increments and decrements. Protect a setmode call with INT{ON,OFF} as it calls malloc internally. PR: 45478 Patch from: Nate Eldredge
* Use the new name H_SETSIZE instead of the old H_EVENT to set the historystefanf2005-10-191-1/+1
| | | | | | size. PR: 86355
* Elaborate on the behaviour of set -e.stefanf2005-09-101-2/+7
|
* Pass the EV_TESTED flag to evalloop() and evalfor(). This fixes unwantedstefanf2005-09-101-8/+8
| | | | | | | | | | | | | | termination with set -e if a command fails in a loop body inside a function with an explicitely tested exit status, eg f() { for i in 1 2 3; do false done } f || true Briefly reviewed by: cracauer
* Pass the EV_TESTED flag to the left operand of NSEMI nodes. This fixesstefanf2005-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | two cases of unwanted termination with set -e: * if-commands containing several commands separated by semicolons, eg if false; false; then [...] * functions with an explicitely tested exit status that contain a failing command which is not the last one, eg f() { false false } f || true PR: 77067, 85267 Briefly reviewed by: cracauer
* Exit the shell if a pipeline that is not preceded by ! fails and set -e isstefanf2005-09-101-3/+7
| | | | | | | active. Use a separate flag to avoid adding another condition to the if-statement at the end of evaltree(). Briefly reviewed by: cracauer
* Split the export synopsis into two lines as -p cannot be mixed with variablestefanf2005-09-091-2/+3
| | | | names.
* - Provide a reasonable error message for `export -p var'.stefanf2005-09-091-1/+3
| | | | - Use argv rather than argptr since getopt() is used here.
* Fix the error message if the mask that is passed to umask -S containsstefanf2005-09-091-1/+1
| | | | non-digits.
* Various small code cleanups resulting from a code reviewingrse2005-09-063-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and linting procedure: 1. Remove useless sub-expression: - if (*start || (!ifsspc && start > string && (nulonly || 1))) { + if (*start || (!ifsspc && start > string)) { The sub-expression "(nulonly || 1)" always evaluates to true and according to CVS logs seems to be just a left-over from some debugging and introduced by accident. Removing the sub-expression doesn't change semantics and a code inspection showed that the variable "nulonly" is also not necessary here in any way (and the expression would require fixing instead of removing). 2. Remove dead code: - if (backslash && c == '\\') { - if (read(STDIN_FILENO, &c, 1) != 1) { - status = 1; - break; - } - STPUTC(c, p); - } else if (ap[1] != NULL && strchr(ifs, c) != NULL) { + if (ap[1] != NULL && strchr(ifs, c) != NULL) { Inspection of the control and data flow showed that variable "backslash" is always false (0) when the "if"-expression is evaluated, hence the whole block is effectively dead code. Additionally, the skipping of characters after a backslash is already performed correctly a few lines above, so this code is also not needed at all. According to the CVS logs and the ASH 0.2 sources, this code existed in this way already since its early days. 3. Cleanup Style: - ! trap[signo][0] == '\0' && + ! (trap[signo][0] == '\0') && The expression wants to ensure the trap is not assigned the empty string. But the "!" operator has higher precedence than "==", so the comparison should be put into parenthesis to form the intended way of expression. Nevertheless the code was effectively not really broken as both particular NUL comparisons are semantically equal, of course. But the parenthesized version is a lot more intuitive. 4. Remove shadowing variable declaration: - char *q; The declaration of symbol "q" hides another identical declaration of "q" in the same context. As the other "q" is already reused multiple times and also can be reused again without negative side-effects, just remove the shadowing declaration. 5. Just small cosmetics: - if (ifsset() != 0) + if (ifsset()) The ifsset() macro is already coded by returning the boolean result of a comparison operator, so no need to compare this boolean result again against a numerical value. This also aligns the macros usage to the remaining existing code. Reviewed by: stefanf@
* fix typo: ommitted -> omittedrse2005-09-061-1/+1
|
* Print pointers with %p rather than casting them to long.stefanf2005-09-052-5/+5
|
* Document that `in word ...' is optional in the for command.stefanf2005-09-031-2/+7
|
* Return 1 from the unalias builtin if _any_ removal fails, not just the laststefanf2005-09-021-1/+1
| | | | one.
* Remove extra getenv() declaration.stefanf2005-09-021-1/+0
|
OpenPOWER on IntegriCloud