summaryrefslogtreecommitdiffstats
path: root/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* The exit status of a case statement where none of the patterns is matchedstefanf2007-10-042-0/+5
| | | | | | | | is supposed to be 0, not the status of the previous command. Reported by: Eygene Ryabinkin PR: 116559 Approved by: re (gnn)
* Take care that the input to setenv() may actually be a pointer straightscf2007-07-061-14/+28
| | | | | | | | from environ; make a copy before manipulating it and passing it to setenv(). Approved by: wes Approved by: re (kensmith)
* Significantly reduce the memory leak as noted in BUGS section forscf2007-07-041-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | setenv(3) by tracking the size of the memory allocated instead of using strlen() on the current value. Convert all calls to POSIX from historic BSD API: - unsetenv returns an int. - putenv takes a char * instead of const char *. - putenv no longer makes a copy of the input string. - errno is set appropriately for POSIX. Exceptions involve bad environ variable and internal initialization code. These both set errno to EFAULT. Several patches to base utilities to handle the POSIX changes from Andrey Chernov's previous commit. A few I re-wrote to use setenv() instead of putenv(). New regression module for tools/regression/environ to test these functions. It also can be used to test the performance. Bump __FreeBSD_version to 700050 due to API change. PR: kern/99826 Approved by: wes Approved by: re (kensmith)
* Back out all POSIXified *env() changes.ache2007-05-011-9/+4
| | | | | | | | | Not because I admit they are technically wrong and not because of bug reports (I receive nothing). But because I surprisingly meets so strong opposition and resistance so lost any desire to continue that. Anyone who interested in POSIX can dig out what changes and how through cvs diffs.
* Simplify previous fix and disallow VTEXTFIXED direct pass for putenv() too,ache2007-04-301-3/+3
| | | | just use savestr()
* Put some safeguards:ache2007-04-301-4/+9
| | | | | | | 1) Under POSIX unsetenv("foo=bar") is explicit error and not equal to unsetenv("foo") 2) Prepare for upcomig POSIXed putenv() rewrite: make putenv() calls portable and conforming to standard.
* Use eaccess() instead of access() for the type builtin, like we do for thestefanf2007-01-181-1/+1
| | | | | | test builtin. Submitted by: Martin Kammerhofer
* Return an error status (127) from the builtins 'type' and 'command' (withstefanf2007-01-111-2/+5
| | | | | | | | | | either -v or -V) if a file with a slash in the name doesn't exist (if there is no slash we already did that). Additionally, suppress the error message for command -v for files with a slash. PR: 107674 Submitted by: Martin Kammerhofer
* Fix expanding of quoted positional parameters in case patterns.stefanf2006-11-071-6/+6
| | | | | | Obtained from: NetBSD (expand.c 1.58 and 1.59) Submitted by: Paul Jarc PR: 56147
* When parsing an invalid parameter expansion (eg. ${} or ${foo@bar}) do notstefanf2006-11-053-9/+25
| | | | | | | | | | | issue a syntax error immediately but save the information that it is erroneous for later when the parameter expansion is actually done. This means eg. "false && ${}" will not generate an error which seems to be required by POSIX. Include the invalid parameter expansion in the error message (sometimes abbreviated with ... because recovering it would require a lot of code). PR: 105078 Submitted by: emaste
* Add the POSIX option -p to the jobs builtin command. It prints the PID of thestefanf2006-10-074-22/+40
| | | | | | | | process leader for each job. Now the last specified option for the output format (-l, -p or -s) wins, previously -s trumped -l. PR: 99926 Submitted by: Ed Schouten and novel (patches modified by me)
* Markup fixes.ru2006-09-171-3/+4
|
* 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
|
OpenPOWER on IntegriCloud