Bug 880 - Incorrect parsing of command lists by /bin/sh
Summary: Incorrect parsing of command lists by /bin/sh
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1995-12-09 17:50 UTC by nnd
Modified: 1995-12-10 18:24 UTC (History)
0 users

See Also:


Attachments
file.diff (60 bytes, patch)
1995-12-09 17:50 UTC, nnd
no flags Details | Diff
file.diff (1.32 KB, patch)
1995-12-09 17:50 UTC, nnd
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description nnd 1995-12-09 17:50:01 UTC
	/bin/sh (ash) incorrectly parse command lists if
	any (but not first) of list components marked as 'background',
	f.e construction

	{ a; b; c & d; e; }

	parsed as if it was

	{ { a; b; c; } & d; e; }

	All other shells which I can test parse this
	as

	{ a; b; { c& } ; d; e; }

	(including /bin/sh in NetBSD-current which is
	 originated from the same sources as FreeBSD one)

Fix: Applay the patch.
(Here is the result of
How-To-Repeat: 
	Try this one:

#!/bin/sh
while true
do
	date +'1:%H:%M:%S'
	sleep 2
	exit
	ps jx &
	date +'2:%H:%M:%S'
	sleep 3
	exit
done

	(while ... do ... done is here to force using
	command-list )
Comment 1 Joerg Wunsch freebsd_committer freebsd_triage 1995-12-10 18:22:28 UTC
State Changed
From-To: open->closed

Suggested fix applied in rev 1.10 of sh/parser.c. 

This does also fix an earlier (non-GNATS) bug report by Ben Jackson 
under the subject ``bug in /bin/sh for loops''.