summaryrefslogtreecommitdiffstats
path: root/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* Document the ulimit -p option in the sh(1) manual page.ed2008-08-301-1/+3
| | | | | | | When I imported the MPSAFE TTY code, I added the -p flag to sh(1)'s ulimit, but I forgot to document it in the appropriate manual page. Requested by: stefanf
* Fix a bug in r177497 which caused the getopts state to be reset when 'set'stefanf2008-08-271-1/+1
| | | | | | was used to set a shell option (and not to change the positional parameters). Submitted by: Martin Kammerhofer
* Integrate the new MPSAFE TTY layer to the FreeBSD operating system.ed2008-08-201-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last half year I've been working on a replacement TTY layer for the FreeBSD kernel. The new TTY layer was designed to improve the following: - Improved driver model: The old TTY layer has a driver model that is not abstract enough to make it friendly to use. A good example is the output path, where the device drivers directly access the output buffers. This means that an in-kernel PPP implementation must always convert network buffers into TTY buffers. If a PPP implementation would be built on top of the new TTY layer (still needs a hooks layer, though), it would allow the PPP implementation to directly hand the data to the TTY driver. - Improved hotplugging: With the old TTY layer, it isn't entirely safe to destroy TTY's from the system. This implementation has a two-step destructing design, where the driver first abandons the TTY. After all threads have left the TTY, the TTY layer calls a routine in the driver, which can be used to free resources (unit numbers, etc). The pts(4) driver also implements this feature, which means posix_openpt() will now return PTY's that are created on the fly. - Improved performance: One of the major improvements is the per-TTY mutex, which is expected to improve scalability when compared to the old Giant locking. Another change is the unbuffered copying to userspace, which is both used on TTY device nodes and PTY masters. Upgrading should be quite straightforward. Unlike previous versions, existing kernel configuration files do not need to be changed, except when they reference device drivers that are listed in UPDATING. Obtained from: //depot/projects/mpsafetty/... Approved by: philip (ex-mentor) Discussed: on the lists, at BSDCan, at the DevSummit Sponsored by: Snow B.V., the Netherlands dcons(4) fixed by: kan
* Mark functions as __dead2 in order to help the LLVM static checkercperciva2008-08-041-1/+1
| | | | | | | understand which code paths aren't possible. This commit eliminates 117 false positive bug reports of the form "allocate memory; error out if pointer is NULL; use pointer".
* Pass the correct flags to expandarg() for NFROMFD and NTOFD. This fixes astefanf2008-07-301-1/+1
| | | | | | | segmentation fault when the argument expands to an empty string. Reported by: simon MFC after: 3 weeks
* use 'const' for the parameters of the two static functions unalias() and ↵rse2008-06-071-4/+4
| | | | hashalias()
* remove an unnecessary includerse2008-06-071-1/+0
|
* Fix checking if a variable name is LINENO. As STPUTC changes the pointer if itstefanf2008-05-281-2/+5
| | | | | | needs to enlarge the buffer, we must not keep a pointer to the beginning. PR: ports/123879
* Expand $LINENO to the current line number. This is required by SUSv3's "Userstefanf2008-05-153-7/+35
| | | | | | | | | Portability Utilities" option. Often configure scripts generated by the autotools test if $LINENO works and refuse to use /bin/sh if not. Package test run by: pav
* Sigh, when reapplying the patch to HEAD, I somehow forgot to commit this file.stefanf2008-04-281-6/+3
| | | | Reported by: Jaakko Heinonen
* - Fix bugs where the value of arithmetic expansion$((...)) was trucatedstefanf2008-04-273-14/+29
| | | | | | | | | | | to type int. - Change the type used for arithmetic expansion to intmax_t (ie. 64 bit on all currently supported FreeBSD architectures). SUSv3 requires at least type long but allows for larger types. Other shells (eg. bash, zsh, NetBSD's sh) do that too. PR: 122659 Submitted by: Jaakko Heinonen (minor modifications by me)
* Reset the internal state used for the 'getopts' built-in when 'shift' or 'set'stefanf2008-03-221-2/+2
| | | | | | | | are used to modify the arguments. Not doing so caused random memory reads or null pointer dereferences when 'getopts' was called again later (SUSv3 says getopts produces unspecified results in this case). PR: 48318
* Split updatepwd() into two smaller functions. The first one, findpwd(),stefanf2008-02-241-38/+45
| | | | | | | | | | computes the new path and the second one, updatepwd(), updates the variables PWD, OLDPWD and the path used for the pwd builtin according to the new directory. For a logical directory change, chdir() is now called between those two functions, no longer causing wrong values to be stored in PWD etc. if it fails. PR: 64990, 101316, 120571
* Fix "warning: comparison is always false due to limited range of data type"marcel2008-02-181-4/+1
| | | | | | | on platforms with unsigned chars. The comparison in question is there to determine whether chars are unsigned or not and is based on comparing a char, initialized to -1, for less than 0. Change the comparison to check for geater than 0 instead...
* Revise the markup.ru2007-12-051-275/+382
|
* Reduce the WARNS level to avoid a compiler warning about a variablejb2007-11-181-1/+1
| | | | possibly being clobbered by a longjmp or a fork with gcc4.
* 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
OpenPOWER on IntegriCloud