summaryrefslogtreecommitdiffstats
path: root/bin/sh/input.c
Commit message (Collapse)AuthorAgeFilesLines
* Sync sh(1) in stable/10 to head.jmmv2014-03-091-18/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a MFC of all the commits listed below. My original goal of this change was to only merge the move of the tests from tools/regression/bin/ into the new layout (which include tests for sh(1) and other tools as well). However, doing so is tricky due to the ongoing work in sh(1) and, especially, the many changes to its tests since stable/10 was first branched. Merging everything is the simplest way to achieve this goal and, as a bonus point, we get various fixes and miscellaneous improvements into the branch. Per jilles' suggestion, I'm avoiding the merge of a couple of changes (r256850 and r257506) that required depending kernel changes. I'm also avoiding very recent changes that have not had a long enough time to be validated in current. This is "make tinderbox" clean. r256735 sh: Remove one syscall when waiting for a foreground job. r257399 sh: Allow trapping SIGINT/SIGQUIT after ignore because of '&'. r257504 sh: Reorder union node to reduce its size on 64-bit platforms. r257920 sh: Add a test case for would-be assignments that are not due to quoting. r257929 sh: Properly quote alias output from command -v. r258489 sh: Add tests for the </dev/null implicit in a background command. r258533 sh: Add more tests for the </dev/null implicit in a background command. r258535 sh: Make <&0 disable the </dev/null implicit in a background command. r258776 sh: Prefer memcpy() to strcpy() in most cases. Remove the scopy macro. r259047 sh: Split set -x output into a separate function. r259210 Migrate tools/regression/bin/ tests to the new layout. r259844 sh: Remove an unused variable. r259846 sh: Initialize OPTIND=1 even if it came from the environment. r259874 sh: Simplify code related to PPID variable. r259946 sh: Don't check input for non-whitespace if history is disabled. r260246 sh(1): Discourage use of -e. r260506 Run the sh(1) and test(1) tests as unprivileged. r260586 Mark the bin/pax tests as requiring perl. r260634 Use TAP_TESTS_PERL to register the legacy_test in bin/pax. r260635 Replace hand-crafted Kyuafiles with automatic generation. r260654 sh: Remove SIGWINCH handler and just check for resize before every read. r261121 sh: Add test for nested alias. r261125 sh: Solve the alias recursion problem in a less hackish way. r261141 sh: Do not depend on parse/execute split in new alias test. r261160 sh: Add tests for alias names after another alias. r261192 sh: Allow aliases to force alias substitution on the following word. r262533 sh: Make expari() static. r262565 sh: Do not corrupt internal representation if LINENO inner expansion fails. r262697 sh: Simplify expari(). Reviewed by: jilles
* sh: Remove #define MKINIT.jilles2013-07-251-1/+1
| | | | MKINIT only served for the removed mkinit. Many variables can be static now.
* sh: Remove mkinit.jilles2013-07-251-6/+3
| | | | | | | | | | | | | | Replace the RESET blocks with regular functions and a reset() function that calls them all. This code generation tool is unusual and does not appear to provide much benefit. I do not think isolating the knowledge about which modules need to be reset is worth an almost 500-line build tool and wider scope for variables used by the reset functions. Also, relying on reset functions is often wrong: the cleanup should be done in exception handlers so that no stale state remains after 'command eval' and the like.
* sh: Use O_CLOEXEC and F_DUPFD_CLOEXEC instead of separate fcntl() call.jilles2013-05-051-5/+4
|
* sh: Fix various compiler warnings.jilles2013-04-011-7/+7
| | | | | | | It now passes WARNS=7 with clang on i386. GCC 4.2.1 does not understand setjmp() properly so will always trigger -Wuninitialized. I will not add the volatile keywords to suppress this.
* sh: Replace an mkinit use with an initialization.jilles2013-01-191-10/+5
|
* sh: Remove an unused variable.jilles2012-11-141-1/+0
|
* sh: Forward-declare struct alias instead of giving up type safety via void *jilles2012-11-111-3/+3
|
* Merge libedit adjustment from NetBSD.pfg2012-07-111-1/+1
| | | | | | | | | | | | | On recent versions of NetBSD's libedit, el_gets now sets el_len to -1 on error so we can distinguish between a NULL string and an error. This fixes sh from exiting with newer versions of libedit now allowing EINTR to return. Obtained from: NetBSD Reviewed by: jilles MFC after: 3 weeks
* sh: Change input buffer size from 1023 to 1024.jilles2012-01-141-6/+6
| | | | PR: bin/161756
* sh: Make various functions static.jilles2012-01-011-1/+2
|
* sh: Reduce more needless differences between error messages.jilles2011-06-041-1/+1
|
* sh: Remove special code for shell scripts without magic number.jilles2011-02-041-6/+1
| | | | | | | | | | These are called "shell procedures" in the source. If execve() failed with [ENOEXEC], the shell would reinitialize itself and execute the program as a script. This requires a fair amount of code which is not frequently used (most scripts have a #! magic number). Therefore just execute a new instance of sh (_PATH_BSHELL) to run the script.
* In the spirit of r90111, depend on c89 and remove the "STATIC" macroobrien2010-10-131-4/+4
| | | | and its usage.
* Consistently use "STATIC" for all functions in order to be able to setobrien2010-10-131-3/+3
| | | | | | breakpoints with in a debugger. And use naked "static" for variables. Noticed by: bde
* sh: Various warning fixes (from WARNS=6 NO_WERROR=1):jilles2009-12-271-3/+3
| | | | | | | - const - initializations to silence -Wuninitialized (it was safe anyway) - remove nested extern declarations - rename "index" locals to "idx"
* sh: Constify various strings.jilles2009-12-241-1/+1
| | | | | Most of this is adding const keywords, but setvar() in var.c had to be changed somewhat more.
* sh: Ensure the same command input file is on top after executing a builtin.jilles2009-11-221-0/+26
| | | | | | | | | | | | | This avoids weirdness when 'fc -e vi' or the like is done and there is a syntax error in the file. Formerly an interactive shell tried to execute stuff after the syntax error and exited. This should also avoid similar issues with 'command eval' and 'command .' when 'command' is implemented properly as in NetBSD sh. Special builtins did not have this problem since errors in them cause the shell to exit or to reset various state such as the current command input file.
* sh: Some changes to stderr flushing:jilles2009-11-211-3/+3
| | | | | | | | | * increase buffer size from 100 to 256 bytes * remove implied flush from out2str(), in particular this avoids unnecessary flushing in the middle of a -x tracing line * rename dprintf() to out2fmt_flush(), make it flush out2 and use this function in various places where flushing is desired after an error message
* Properly flush input after an error in backquotes in interactive mode.jilles2009-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | For parsing an old-style backquote substitution (`...`), a string "file" is used to store the contents of the substitution (with the special backslash processing done). If an error occurs, the shell cleans up all these files (returning to the top level) and flush the top level file. Erroneously, it first flushed the current file and then cleaned up all extra files, so that the top level file (i.e. the terminal) was not flushed. Example (in interactive mode): echo `for` echo This should not be printed Also noticeable in (in interactive mode): echo `(` The old version prints an extraneous prompt. Approved by: ed (mentor)
* Avoid leaving unnecessary waiting shells in many forms of sh -c COMMAND.jilles2009-06-131-0/+17
| | | | | | | | | | | | | | | | | | | | | | This change only affects strings passed to -c, when the -s option is not used. The approach is to check if there may be additional data in the string after parsing each command. If there is none, use the EV_EXIT flag so that a fork may be omitted in specific cases. If there are empty lines after the command, the check will not see the end and forks will not be omitted. The same thing seems to happen in bash. Example: sh -c 'ps lT' No longer shows a shell process waiting for ps to finish. PR: bin/113860 Reviewed by: stefanf Approved by: ed (mentor)
* 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
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* Replace home-grown dup2() implementation with actual dup2() calls. Thisdes2004-01-211-1/+1
| | | | | | | 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
* Changes following CScout analysis:dds2003-07-051-1/+1
| | | | | | | | | | | - Removed dead declarations - Made objects that should have been declared as static, static. The changes use STATIC instead of static, following the existing convention in the rest of the code. Approved by: schweikh (mentor) MFC after: 2 weeks
* Avoid calling el_resize() from a signal handler, even though libedittjr2002-07-241-0/+7
| | | | | | | itself does that if you set EL_SIGNAL. Instead, set a flag and check it before calling el_gets(). This is safer, but slower to respond to changes. Pointed out by: mp
* Consistently use FBSDIDobrien2002-06-301-2/+2
|
* o __P has been reovedimp2002-02-021-28/+23
| | | | | | | | | | | | | | | | | | 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) { ...
* *** empty log message ***obrien2001-10-011-1/+3
|
* Include strerror(errno) in error messages after failed system calls.cracauer1999-11-291-1/+1
| | | | Fix a warning.
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* First set of fixes to keep egcs happy. These include {} around singleimp1999-04-251-2/+1
| | | | | | | | | | statement if blocks[*] when the else could be ambiguous, not defaulting to int type and removal of some unused variables. [*] This is explicitly allowed by style(9) when the single statement spans more than one line. Reviewed by: obrien, chuckr
* Add rcsid. Spelling.charnier1998-05-181-3/+5
|
* Nuke register keyword usage, rename pread to preadfd, and opensteve1997-04-281-7/+9
| | | | | | input files FD_CLOEXEC. 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-12/+15
| | | | Obtained from: NetBSD, me
* Fix for PR#1287. This makes sh behave sensibly in case statements in thepeter1996-09-031-5/+4
| | | | | | | | | | | | | | face of aliases. Note, bash doesn't do aliases while running scripts, but "real" ksh does.. Also: Reduce redundant .Nm macros in (unused) bltin/echo.1 nuke error2, it's hardly used. More -Wall cleanups dont do certain history operations if NO_HISTORY defined handle quad_t's from resource limits Submitted by: Steve Price <sprice@hiwaay.net> (minor tweaks by me)
* Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is apeter1996-09-011-15/+20
| | | | | | | | | | | | | | 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
* Implement allowing 'set -v' in the middle of a script to work.peter1995-11-031-78/+103
| | | | | | | | | | | | | | | This means that a script containing: echo 1 set -v echo 2 will now produce output, like it does on SYSV machines and other 'proper' /bin/sh implementations.. This is done by a slight restructure of the input processor allowing it to read chunks from the file at a time, but process the data by line from the chunk. Obtained from: Christos Zoulas for NetBSD. <christos@deshaw.com>
* Remove trailing whitespace.rgrimes1995-05-301-3/+3
| | | | Reviewed by: phk
* Added $Id$dg1994-09-241-0/+2
|
* BSD 4.4 Lite bin Sourcesrgrimes1994-05-261-0/+474
OpenPOWER on IntegriCloud