summaryrefslogtreecommitdiffstats
path: root/bin/sh/parser.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix various things about SIGINT handling:jilles2009-11-221-1/+1
| | | | | | | | | | | | | | | | | | * exception handlers are now run with interrupts disabled, which avoids many race conditions * fix some cases where SIGINT only aborts one command and continues the script, in particular if a SIGINT causes an EINTR error which trumped the interrupt. Example: sh -c 'echo < /some/fifo; echo This should not be printed' The fifo should not have writers. When pressing ctrl+c to abort the open, the shell used to continue with the next command. Example: sh -c '/bin/echo < /some/fifo; echo This should not be printed' Similar. Note, however, that this particular case did not and does not work in interactive mode with job control enabled.
* sh: Some changes to stderr flushing:jilles2009-11-211-0/+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
* sh: Allow a newline before "in" in a for command, as required by POSIX.jilles2009-11-141-1/+3
|
* sh: Show more information about syntax errors in command substitution:jilles2009-10-161-0/+5
| | | | | | | the line number where the command substitution started. This applies to both the $() and `` forms but is most useful for `` because the other line number is relative to the enclosed text there. (For older versions, -v can be used as a workaround.)
* sh: Disallow mismatched quotes in backticks (`...`).jilles2009-10-011-7/+1
| | | | | | | | | Due to the amount of code removed by this, it seems that allowing unmatched quotes was a deliberate imitation of System V sh and real ksh. Most other shells do not allow unmatched quotes (e.g. bash, zsh, pdksh, NetBSD /bin/sh, dash). PR: bin/137657
* sh: Improve handling of setjmp/longjmp volatile:jilles2009-06-231-19/+1
| | | | | | | | | | | - remove ineffective and unnecessary (void) &var; [1] - remove some unnecessary volatile keywords - add a necessary volatile keyword - save the old handler before doing something that could use the saved value Submitted by: Christoph Mallon [1] Approved by: ed (mentor)
* correctly test for __GNUC__ macro (non-GCC compilers do not have it defined ↵rse2009-06-011-2/+2
| | | | at all)
* Parse 'cmd1 && ! cmd2 | cmd3' correctly, the bang should apply to the entirestefanf2009-04-131-0/+1
| | | | | | | pipeline cmd2 | cmd3 and not just cmd2. PR: 130298 Submitted by: Jilles Tjoelker
* 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-151-3/+22
| | | | | | | | | 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
* When parsing an invalid parameter expansion (eg. ${} or ${foo@bar}) do notstefanf2006-11-051-9/+19
| | | | | | | | | | | 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
* 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
* Remove a hack for an ancient gdb.stefanf2005-08-151-13/+4
|
* Put the comparison with PEOF into a new macro is_eof(). Don't use it if thestefanf2005-08-131-3/+4
| | | | character comes from a string.
* Use assignment rather than comparison.stefanf2005-08-131-2/+2
|
* Include missing headers.stefanf2005-08-131-0/+1
|
* Support \H, \h, \w, \W, \$ string expansion in the prompt.obrien2005-03-011-4/+91
| | | | Submitted by: mini
* 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/+0
| | | | | | | 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-11/+11
| | | | | | | | | | | - 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
* Disallow empty condition parts of "if", "while" and "until" compoundtjr2002-10-061-3/+6
| | | | | | commands. Commands like "if then ... fi" and "while do ... done" are no longer accepted. Bodies of compound commands are still allowed to be empty, because even though POSIX does not allow them, most shells do.
* Remove bits and pieces of support for atty, which was made obsolete bytjr2002-10-011-10/+0
| | | | | | adding history and vi/emacs-style line editing to the shell itself. Atty was a user-mode terminal emulator (like screen and window) that did line editing and history.
* Allow a left parenthesis before patterns in case blocks. POSIX requirestjr2002-09-301-0/+2
| | | | us to accept this, but I've never seen a script that uses it.
* Allow empty case/esac statements; POSIX requires this, and recent versionstjr2002-09-301-2/+2
| | | | | | | of autoconf are generating scripts that use this feature. PR: 43275 35879 Submitted by: Dan Nelson <dnelson@allantgroup.com>
* Replace various spellings with FALLTHROUGH which is lint()ablecharnier2002-08-251-1/+1
|
* Allow redirections by themselves between "&&" and "||" operators.tjr2002-08-111-3/+2
| | | | | | | For example, >/dev/null && echo foo Pointed out by: FUJISHIMA Satsuki MFC after: 1 week
* Don't allow "||" or "&&" to be the first tokens of a command.tjr2002-07-221-0/+1
| | | | | PR: 40386 MFC after: 2 weeks
* Consistently use FBSDIDobrien2002-06-301-2/+2
|
* Minor const cleanup.jmallett2002-06-201-2/+2
| | | | Don't discard qualifiers we don't need to discard.
* Implement the -C (-o noclobber) option, which prevents existing regulartjr2002-05-191-0/+2
| | | | files from being overwritten by shell redirection.
* o __P has been reovedimp2002-02-021-59/+52
| | | | | | | | | | | | | | | | | | 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) { ...
* BASESYNTAX, DQSYNTAX, SQSYNTAX and ARISYNTAX handles negative indexes.tegge2001-09-191-2/+2
| | | | | Allow those to be used to properly quote characters in the shell control character range.
* ``|'' should be more binding than ``!'' so that this isn't broken:brian2001-04-091-2/+13
| | | | | | | | if ! echo bla | wc -c ; then echo broken fi Obtained from: NetBSD
* A much better (more correct) fix for handling ``!'' charactersbrian2001-04-041-23/+40
| | | | Obtained from: NetBSD
* Handle ``!'' characters when they appear as second and subsequentbrian2001-04-041-0/+3
| | | | | | | | parts of an && or || expression. This makes this expression work as expected: if true && ! false; then echo yes; fi
* Implement the <> redirection operator.brian2000-10-031-0/+2
|
* Disable part of my 8-bits fixes from December 1999.cracauer2000-08-161-4/+1
| | | | | | | | Serious fix still needed, see discussion on -current (Subject: /bin/sh dumps core with here-document of 8bit text) Problem in this code originally spotted by Jun Kuriyama <kuriyama@FreeBSD.org>
* Fix parsing of string for eval command.cracauer2000-05-151-0/+1
| | | | | PR: 18447 Submitted by: Koji Mori <mori@tri.asanuma.co.jp>
* Fix warnings, some of them serious because sh violated namecracauer2000-04-201-2/+1
| | | | | | | | spaces reserved by the header files it includes. mkinit.c still produces C code with redundant declarations, although they are more harmless since they automatically derived from the right places.
* Fix ${#varname} (getting length of string) when in double-quotes.cracauer2000-02-151-1/+1
| | | | | | | Approved-by: jkh PR: bin/12137 Submitted by: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
* Second part of 8-bit fixes.cracauer1999-12-161-1/+9
|
* First round of 8-bit fixes.cracauer1999-12-151-4/+5
|
* Fix "subscript has type `char'" warnings by casting to int, ascracauer1999-12-041-1/+1
| | | | discussed on -arch.
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Be more consistent with handling of quote mark control character.tegge1998-09-131-9/+19
| | | | | | | Don't output double-quotes inside variable expansion/arithmetic expansion region in here-documents. When leaving the arithmetic expansion syntax mode, adjust the dblquote flag according to previous syntax, in order to avoid splitting of quoted variables.
* Better handling of word splitting. Don't record the same regiontegge1998-09-061-1/+10
| | | | | | multiple times when performing nested variable expansion, and preserve some quoting information in order to avoid removing apparently empty expansion result.
* Add rcsid. Spelling.charnier1998-05-181-3/+5
|
* Use the __unused attribute where warranted.steve1997-05-191-3/+3
|
* Revert changes from rev 1.16 to 1.17 for now. Closes PR 2879.steve1997-04-281-49/+29
|
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
OpenPOWER on IntegriCloud