Commit Graph

53 Commits

Author SHA1 Message Date
christos f629aa28d9 implement noclobber. From Ben Harris, with minor tweaks from me. Two
unimplemented comments to go. Go Ben!
2002-05-15 16:33:35 +00:00
christos 8b449b1ee8 enami convinced me that it is a good idea to use the first word of
the allocated area.
2002-02-20 21:42:35 +00:00
christos 6c02afd8c4 Since we should be able to handle nested double quotes, don't use
the syntax maps to determine the beginning and end quotes (kill
CENDQUOTE).  Handle single quotes opening and closing via checking
the current syntax map. Keep a bitmap of doublequote state one bit
per variable nesting level.  For the first 32 nested double quotes,
we don't need any additional memory, but for more we allocate
dynamically.
2002-02-12 20:32:35 +00:00
ross 79f9ab6771 back this directory up a day, systems won't even boot (rc.subr splodes)
suggested back-to-the-drawing-board test: $ echo "${PWD:-notlikely}"
2002-02-12 06:39:10 +00:00
christos f63e9a1ed6 PR/15579: Alan Barrett: }'s inside variable specs were taken into account
even if quoted:
    foo=${foo:-"'{}'"}; echo $foo
would display '{'} instead of '{}'.
2002-02-11 18:57:19 +00:00
christos 0598afe4d0 Fix switch alias handling. Inspired from FreeBSD, but corrected to handle
alias expansion inside the switch as appropriate. This is achieved by a
flag noalias which is turned on and off in as we parse. In the following
example [1] and [0] indicate the value of noalias.

[0] case <expr> in
[1] <lit> ) [0] <expr> ;;
[1] <lit> ) [0] <expr> ;;
...
[1] esac [0]

FreeBSD does:

[0] case <expr> in [1]
<lit> ) <expr> ;;
<lit> )  <expr> ;;
...
esac [0]

This handles the following shell script:

alias a=ls

case $1 in
a)	echo a;
	a;;
f)	echo f;;
*)	echo default;;
esac
2001-11-02 23:49:14 +00:00
christos ea8e5cf90b PR/12533: Koji Mori: eval gets misparsed when it has a trailing semi-colon. 2001-04-03 15:00:11 +00:00
christos 3380980447 remove redundant declarations and nexted externs. 2001-02-04 19:52:06 +00:00
cgd 2a1ee59131 un-__P functions declared in parser.h. host programs include parser.h,
and so it shouldn't use __P.  (this should probably be done better, by
not declaring the parser functions in headers used by host programs,
but this works well enough.)
2000-07-27 04:09:27 +00:00
christos d6ac7627ea Fix bin/9184, bin/9194, bin/9265, bin/9266
Exitcode and negation problems (From Martin Husemann)
2000-01-27 23:39:38 +00:00
christos 3d42469030 compile with WARNS = 2 1999-07-09 03:05:49 +00:00
christos 6e50d7a816 PR/4966: Joel Reicher: Implement <> redirections which are documented in
the man page.
1999-02-04 16:17:39 +00:00
mycroft 1fbf0781c6 Patches from Tor Egge (via Havard Eidnes) to fix various bugs in field
splitting and combining.
(Note: Some of this are not strictly bugs, but differences between traditional
Bourne shell and POSIX.)
1999-01-25 14:20:56 +00:00
itohy ef88b5d2bd Fixed memory leak on old style command substitution
such as  sh -c 'echo `echo foo`' .
The memory allocated with ckmalloc() at
parser.c:1349:readtoken1() (search for "done:" label)
was never freed.

I changed this to use 'string stack' framework of Ash.
Note that a string on string stack is properly freed on
exception and end of command parsing, and no explicit free
or signal handlings required.
See TOUR for an overview, and memalloc.[ch] for details
of string stack.
1998-09-26 20:56:33 +00:00
mycroft ee9e50eacb Be more retentive about use of NOTREACHED and noreturn. 1998-07-28 11:41:40 +00:00
mrg a26bae1e08 - change "extern" variables into int's
- remove extern'd variables not actually referenced
- don't use char as an array index
1998-03-29 04:41:43 +00:00
christos 1eb178df64 Fix Sparcworks warnings. 1997-07-15 17:45:53 +00:00
christos cd799663e4 Fix compiler warnings. 1997-07-04 21:01:48 +00:00
christos 7accaec421 NO_HISTORY->SMALL 1997-03-14 01:42:18 +00:00
christos 6f224ae59f Fix parsing problem introduced in the previous ${10} fix, where $#digit
or $digit# would get mis-parsed as a positional parameter.
1997-01-26 18:05:34 +00:00
christos 3d5f212ba8 enable parsing of multi-digit positional arguments i.e. ${10} works and it
is not a bad substitution.
1997-01-24 17:15:56 +00:00
tls 48250187e6 kill 'register' 1997-01-11 02:04:27 +00:00
christos 340077b543 - fix parsing bug reported by mycroft: ! was only recognized in the beginning
of pipelines. Now we are recognizing it everywhere like ksh, so:

	! if [ a = b ]; then ! echo c && ! true; else ! echo d; fi

  works.
1996-11-25 20:22:00 +00:00
christos d8c242f0ae PR/2808: - detect eof inside backquotes
- handle && and || shortcircuits properly
	 - tokens.def -> tokens.h
	 (from FreeBSD)
1996-10-16 14:53:23 +00:00
christos 55a41e8abb Close PR/2384 backquoted backslash-newline was not eaten. 1996-05-09 19:40:08 +00:00
christos b09ffc42b1 - parser.c: Fix prompting in old style backquote expansion. Fixes PR/2139
and many user complaints why the shell hangs in echo "`"
- eval.c:   Fix exitstatus invalid resetting in `if' statements were:
		if (exit 3); then
			echo foo $?
		else
			echo bar $?
		fi
	    printed 'bar 0' instead of bar 3
1996-03-05 21:03:52 +00:00
christos 893ade3fac - fix PR1620, -DNO_HISTORY did not work.
- restore parsing state after parsing old style command substitution.
  The ';' in '`echo z;`' broke the following:
	for i in 1; do
		cat > /dev/tty << __EOF__
		`echo z;`
		__EOF__
	done

cVS: Enter Log.  Lines beginning with `CVS: ' are removed automatically
1995-10-19 04:14:37 +00:00
christos 56a08eccca Fixed bug where ${#} was interpreted incorrectly as ${#var} and thus
misparsed. Keith Bostic reported it.
1995-05-17 00:05:25 +00:00
christos 07bae7eddd Merge in my changes from vangogh, and fix the x=`false`; echo $? == 0
bug.
1995-05-11 21:28:33 +00:00
cgd 49f0ad8601 convert to new RCS id conventions. 1995-03-21 09:01:59 +00:00
christos ad8d5369f5 I added the documented in the manual but not implemented variable expansions:
${#WORD}
    ${WORD%PAT}
    ${WORD%%PAT}
    ${WORD#PAT}
    ${WORD##PAT}
1995-01-23 06:33:03 +00:00
cgd 4ce0d34a31 clean up further. more patches from Jim Jegers 1994-12-05 19:07:32 +00:00
mycroft 06f53b6838 Eliminate uses of some obsolete functions. 1994-09-23 11:28:39 +00:00
mycroft 08a6730054 Fix a core dump and another parse error related to null commands. 1994-08-24 05:48:26 +00:00
mycroft aaed410145 Fix some problems with empty commands. 1994-07-07 20:53:32 +00:00
jtc 918ce04f57 From Christos:
1. Fix `-' quoting in [ ] expressions.
  2. Fix expansion of variables in redirections
1994-06-14 05:49:19 +00:00
mycroft cafd1f7e9f Add RCS ids. 1994-06-11 16:11:35 +00:00
jtc 20ddd6eee4 Fixed another case statement parsing bug that was introduced by my
last fix :-(.  Thanks to Theo for letting me know about it...
1994-06-01 21:36:54 +00:00
jtc d8e5937418 Re-worked case statement parsing. With luck, this fixes bug #268. 1994-05-30 20:05:40 +00:00
cgd 242337bcae a few more things to omit when NO_HISTORY defined. from noel@cs.oberlin.edu 1994-05-21 01:42:30 +00:00
jtc 1af99404cd Fix backslash parsing within backquoted string 1994-05-17 10:47:50 +00:00
jtc 83b8a2f413 Mark Weaver's background/list fix (for bug #236) 1994-05-11 17:39:11 +00:00
jtc 37ed7877b2 sync with 4.4lite 1994-05-11 17:09:42 +00:00
cgd 7f42c5de51 from jim wilson: (command): Handle TEOF like TNL. 1993-09-09 01:21:43 +00:00
mycroft f0e18400d3 Make `>file;' work. 1993-09-06 00:44:46 +00:00
mycroft 8542364e07 Add RCS identifiers. 1993-08-01 18:49:50 +00:00
jtc 6659413c9a Another change from Jim Wilson. 1993-07-15 22:12:02 +00:00
jtc 67893cfee5 IEEE 1003.2 (D11.2.2.3) requires that the system's true and false be accessed
instead of searching $PATH.  The best way to satisfy this requirement is to
make them builtins.

True was allready builtin, this patch adds false.
1993-07-07 01:11:56 +00:00
sef 5916a08554 Jim "wilson@moria.cygnus.com" Wilson's patches to make C News (and other
things) work.
1993-05-02 01:28:40 +00:00
dpassage 2d12aa06fa Fixed incorrect calls to longjmp. 1993-04-26 22:07:46 +00:00