summaryrefslogtreecommitdiffstats
path: root/bin/sh/eval.c
Commit message (Collapse)AuthorAgeFilesLines
* 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-151-3/+8
| | | | | | | | | | | | 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
* Implement some of the differences between special built-ins and other builtinsstefanf2006-04-091-13/+9
| | | | | | | | | | | | | | | | | | | | 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.
* Remove some white space at EOL.schweikh2006-02-041-3/+3
|
* Add the times builtin. It reports the user and system time for the shellstefanf2005-12-041-0/+26
| | | | | | 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.
* Add the POSIX options -v and -V to the 'command' builtin. Both describe thestefanf2005-10-281-1/+13
| | | | | | | type of their argument, if it is a shell function, an alias, a builtin, etc. -V is more verbose than -v. PR: 77259, 84539
* 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
* Print pointers with %p rather than casting them to long.stefanf2005-09-051-3/+3
|
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* The PR diff I committed recently had one bug noticed bycracauer2004-01-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Joe Marcus Clarke <marcus@FreeBSD.ORG>, subshells could lose a non-zero exit status. This commit is Joe's proposed patch. Thanks! I verified that the problem Joe found is fixed and I ran a full world with this patch. I don't plan to ever commit language patches to /bin/sh again. It is a minefield too big to navigate without a full-time committment, which I am not willing to do on our /bin/sh. Under normal circumstances I would recommend using NetBSD's sh which has a lot of language fixes (like the ones what these patches were about) but unfortunately they had implemented broken signal behaviour for shellscript containing interactive programs. Similar issues apply to pdksh which is OpenBSD's sh. From my perspective bash2 is the only really working bourne sh out there and that one is GPLed. Oh well.
* Replace home-grown dup2() implementation with actual dup2() calls. Thisdes2004-01-211-8/+4
| | | | | | | should slightly reduce the number of system calls in critical portions of the shell, and select a more efficient path through the fdalloc code. Reviewed by: bde
* o Spell 'diretories' correctly.maxim2003-12-301-1/+1
| | | | | | PR: misc/60730 Submitted by: Eugene Grosbein MFC after: 3 days
* PR 28852cracauer2003-12-281-24/+1
| | | | | | | | | | | | | | | sh -e behaviour was incorrect when && and || statements where used in "if" clauses. This is the patch submitted by MORI Kouji <mori@tri.asanuma.co.jp>. It fixes the issue at hand, but sh fixes like this are super-hard to verify that they don't break anything else. I ran some of my old test cases and a few big GNU configure scripts that detected mistakes before, with the previous sh, patched sh and bash. No differences in behaviour found. MFC recommended after longer than usual time. Compiles on i386 and sledge.
* Make this compile with DEBUG defined now that WARNS=0 has been removedtjr2003-01-211-1/+1
| | | | | | | | from the Makefile: - Print pointers with %p instead of %x. - Include missing headers to get prototypes. Noticed by: benno
* Add <stdlib.h> to get a prototype for exit().keramida2002-08-291-0/+1
| | | | Reviewed by: tjr
* Set opterr to zero to avoid duplicate warnings from getopt(3) for unknowntjr2002-07-251-0/+1
| | | | options.
* Implement the P1003.2 `command' builtin command, which is used to suppresstjr2002-07-211-2/+54
| | | | | | shell function and alias lookup. The -p option has been implemented, the UPE -v and -V options have not. The old `command' command has been renamed to `builtin'.
* Consistently use FBSDIDobrien2002-06-301-2/+2
|
* Implement the -C (-o noclobber) option, which prevents existing regulartjr2002-05-191-0/+1
| | | | files from being overwritten by shell redirection.
* o __P has been reovedimp2002-02-021-58/+27
| | | | | | | | | | | | | | | | | | o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. o Change int foo() { ... to int foo(void) { ...
* Fix how /bin/sh handles 'for' and 'case' statements when it is called to dogad2001-06-011-0/+16
| | | | | | | | errexit (-e) processing. This solves a problem where 'make clean' would fail with an unspecified error in certain automake-generated makefiles. Reviewed by: no objections from -hackers... MFC after: 2 weeks
* Implement the <> redirection operator.brian2000-10-031-0/+1
|
* Fix environment passung to eval'ed commands.cracauer2000-05-151-0/+1
| | | | | | PR: bin/6577 Submitted by: Anatoly Vorobey <mellon@pobox.com> Approved by: silence amoung other sh experts
* Fix command hash handling oncracauer1999-12-201-1/+27
| | | | | | PATH=... command Noted by and fix works for Marcel Moolenaar <marcel@scc.nl>
* Include strerror(errno) in error messages after failed system calls.cracauer1999-11-291-3/+4
| | | | Fix a warning.
* The pipleline problem introduced in version 1.22 wasn't fully fixed incracauer1999-11-171-1/+1
| | | | | | | 1.23. This revision should work for long pipes both in here-documents/backquote and in normal cases. Fix works for jmz, bde.
* Correct logic from previous commit - middle processes in long pipessteve1999-11-071-1/+1
| | | | | | don't have their stdin closed indisciminantly. Reviewed by: markm
* When a backquote command inside a here-document had a pipe with morecracauer1999-11-051-1/+2
| | | | | | | | than two processes (got that? :-), the stdin fd of the middle processes that has just been set up was accidetially closed. Don't do this. PR: bin/14527
* Fix ';' command when used with -e flag.cracauer1999-10-261-1/+8
| | | | PR: bin/14509
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Fix handling of the cd command inside evaluations. It was changing PWD,sheldonh1999-07-191-1/+2
| | | | | | | | which it should not do. PR: 12578 Reported by: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> Submitted by: Niall Smart <niall@pobox.com>
* Various spelling/formatting changes.kris1999-05-081-2/+2
| | | | Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
* Next approach to make loops in interactive interruptable.cracauer1999-04-211-5/+6
| | | | PR: bin/9173
* In interactive shells, break loops to the topmost level when a childcracauer1999-04-031-1/+6
| | | | | | | | | is killed by a signal. (In non-interactive shells - that means a shellscript - the shell just exits, this was already working) PR: bin/9173
* The immediate execution of traps I introduced in September 1998 (tocracauer1999-04-011-2/+3
| | | | | | | | | | make /etc/rc interruptible in cases when programs hang with blocked signals) isn't standard enough. It is now switched off by default and a new switch -T enables it. You should update /etc/rc to the version I'm about to commit in a few minutes to keep it interruptible.
* Add rcsid. Spelling.charnier1998-05-181-3/+5
|
* When calling a shell function, remember whether exit status is tested.cracauer1998-05-041-2/+5
| | | | | | This is needed for the '-e' option. See the PR for more details. PR: 6047 Reviewed by: PR submitter, silence on review request.
* Use the __unused attribute where warranted.steve1997-05-191-7/+7
|
* Nuke register keyword usage and #if -> #ifdef.steve1997-04-281-2/+2
| | | | Obtained from: NetBSD
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Merge in NetBSD mods and -Wall cleaning.steve1996-12-141-42/+40
| | | | Obtained from: NetBSD, me
* Back out rev 1.7 which was to fix PR#1206 (to be reopened).peter1996-11-121-19/+2
| | | | | | | | | | This patch causes too many side effects, one of which bites hard is when interrupting a 'make fetch' in the ports tree (PR#1990). This whole area is a real can of worms.... This most definately should go into 2.2 Reviewed by: steve, bde
* Close PR# 1206. sh(1) now ignores SIGINT and SIGQUITsteve1996-10-221-3/+19
| | | | | | | when a child is forked and the -c commandline switch has been specified. Reviewed by: joerg
* Fix a problem with sh that conflicts with the -esteve1996-10-061-2/+5
| | | | | | | | | flag text in the man page. Now this will work correctly: /bin/sh -ec 'false && true; echo hi' Obtained from: VaX#n8 <vax@linkdead.paranoia.com>
* Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is apeter1996-09-011-76/+144
| | | | | | | | | | | | | | merge of parallel duplicate work by Steve Price and myself. :-] There are some changes to the build that are my fault... mkinit.c was trying (poorly) to duplicate some of the work that make(1) is designed to do. The Makefile hackery is my fault too, the depend list was incomplete because of some explicit OBJS+= entries, so mkdep wasn't picking up their source file #includes. This closes a pile of /bin/sh PR's, but not all of them.. Submitted by: Steve Price <steve@bonsai.hiwaay.net>, peter
* Don't dereference a NULL pointer in the case of a null pipe.dg1995-09-201-2/+3
| | | | | | | e.g.: ls |> foo.out sh now behaves the same as it does under SunOS 4.x for this case.
* Remove trailing whitespace.rgrimes1995-05-301-4/+4
| | | | Reviewed by: phk
OpenPOWER on IntegriCloud