Commit Graph

424 Commits

Author SHA1 Message Date
christos dde7426849 From David Laight
> The wrong process is aborting when variable assignment fails
> in the vfork path.  So the following command fails to execute
> the second echo (shown here with the correct output).
>
> $ (readonly r; r= /bin/echo a; echo b)
> r: is read only
> b
>
> fix: defer the mklocal() to the child shell.
2002-10-23 19:46:34 +00:00
christos f3dfd6e686 From David Laight:
> Also 'jobs' fails in a non-interactive shell.
> In showjobs(), the code that puts the process back into its
> own process group should only be run if the shell is actually
> doing job control - eg if 'mflag' is set.
2002-10-23 19:46:06 +00:00
christos 6166cc6e93 Fix interrupt problam from David Laight
$ /fred # non existant command
$ ^C # stops working

He says:
    Ok the extra INTOFF is the one in exverror().
    In almost all cases this doesn't matter because the longjmp()s
    all end up in main() and the FORCEINTON call sorts it out
    for the next command.
    (There are a significant number of INTON/OFF mismatches through
    the error paths...)

    In any case the above failure can be 'fixed' by changing 2 (I think
    they are both needed) INTON calls to FORCEINTON within evalcommand.
    The following patch seems to work:

We should really look in the code and fix the INTON->INTOFF pairs.
2002-10-23 13:25:24 +00:00
lukem e490a5c798 don't compile in `-h' as a synonym for the command that the argument is for.
this fix is hokey, but works as well as the previous solution for -j.
2002-10-15 04:15:58 +00:00
christos 1ce87c4b29 - it is wrong to put inton/intoff arount ckmalloc(), because the code
around it is the one that does this.
- whitespace fixes.
2002-10-07 14:26:49 +00:00
christos 202746f803 explain what's breaking with alignments > 16, but no fix yet. 2002-10-07 14:26:08 +00:00
christos b9d3050e20 Rename ALIGN to SHELL_ALIGN and simplify macro so that it does not have side
effects, and add double to it, so that it aligns doubles correctly too. This
is just a workaround to fix the sparc64 problem where ALIGN() is now defined
in some include file to be 16 instead of 8. Thanks to martin for debugging this.
2002-10-04 13:15:51 +00:00
wiz 1da66f1f4c filesystem -> file system, automaticly -> automatically. 2002-10-02 10:01:46 +00:00
wiz 2e6e2165c0 Use more mdoc, particularly to get rid of some \*[Lt] and \*[Gt]. 2002-10-01 15:06:31 +00:00
mycroft 6092f7d52b Revert the previous for now. This is truly gross. 2002-09-28 03:15:43 +00:00
mycroft 7973b7a0ac Remove the duplicate setpgid() in forkparent(). The real bug was freeing the
job structure in the child and referencing freed memory.
2002-09-28 03:08:00 +00:00
christos 4783843fdc Revert previous change. No need to save rootshell. It is only affecting
the non-vfork case. Having said that, it would be nice if pipelines of
simple commands were vforked too. Right now they are not.
Explain that setpgid() might fail because we are doing it both in the
parent and the child case, because we don't know which one will come
first.
Suspending a pipeline prints %1 Suspended n times where n is the number
of processes, but that was there before. It is easy to fix, but I'll
leave the code alone for now.
2002-09-28 01:25:01 +00:00
christos 6f48233483 Deal with rootshell not being maintained correctly in the vfork() case.
Propagate isroot, throughout the eval process and maintain it properly.
Fixes sleep 10 | cat^C not exiting because sleep and cat ended up in
their own process groups, because wasroot was always true in the children.
2002-09-27 22:56:24 +00:00
mycroft d84d36165d Clean up INTOFF/INTON usage a little -- none of fork{shell,parent,child}()
screw with them now, only their callers.
2002-09-27 21:32:24 +00:00
christos ad1e7bca30 off by one in nprocs. 2002-09-27 21:04:08 +00:00
christos 35975338b0 Put back charles' fixes from -r1.60 2002-09-27 20:24:36 +00:00
christos edcb454443 VFork()ing shell: From elric@netbsd.org:
Plus my changes:
	- walking process group fix in foregrounding a job.
	- reset of process group in parent shell if interrupted before the wait.
	- move INTON lower in the dowait so that the job structure is
	  consistent.
	- error check all setpgid(), tcsetpgrp() calls.
	- eliminate unneeded strpgid() call.
	- check that we don't belong in the process group before we try to
	  set it.
2002-09-27 18:56:50 +00:00
mycroft 2aa6ebd4ed In evalpipe(), move the INTOFF after the waitforjob(), to prevent possible
race conditions -- now we always synchronously wait for the job to finish.
In evalcommand(), add the same INTOFF/INTON locking as evalpipe(), to prevent
leaving internal state inconsistent, and also to insure that we synchronously
wait for the job.
2002-09-27 17:37:12 +00:00
christos 6438e7dcdc no SYSV for eagain, enable EMFILE 2002-09-27 16:56:15 +00:00
wiz 14dfaa4b03 New policy: New sentences start on a new line.
Patches by Robert Elz <kre at munnari oz au>, with minimal changes by me.
2002-09-25 15:18:36 +00:00
thorpej e41b1aa4a2 Use "unsigned char" and "char" instead of "u_int8_t" and "int8_t"
for TARGET_CHAR when building mksyntax.  This isn't perfect, but
it lets the host tool work on non-BSD systems without completely
redoing how sh is built.
2002-09-15 00:19:22 +00:00
lukem 146a774973 Use ${NETBSDSRCDIR}/some/path instead of ${.CURDIR}/../../some/path (etc). 2002-08-19 09:56:00 +00:00
christos 82886e162e deal with char c; c != -129 warning. Hi jason! 2002-05-31 16:18:48 +00:00
wiz 10610e5a31 __STDC__ is always defined on NetBSD. 2002-05-25 23:12:16 +00:00
wiz 0b398b282c __STDC__ is always defined on NetBSD, so remove #ifdef __STDC__ (and
unnecessary #else cases).
2002-05-25 23:09:06 +00:00
bjh21 84c006d0f8 The printf builtin has been "temporarily" disabled for eight years. Remove
its directory from .PATH to avoid confusion.
2002-05-15 20:45:17 +00:00
bjh21 6f786375c4 Implement sh -a (allexport). Code (all two lines of it) from FreeBSD
(FreeBSD var.c 1.13, sh.1 1.27).
2002-05-15 19:43:29 +00:00
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 eac955176d Implement unset variable error messages from Ben Harris. 2002-05-15 14:59:21 +00:00
christos de525ac6ca Try harder to find a tty. 2002-04-10 15:52:07 +00:00
thorpej 3ea17f6cff Move the declaration of digit[] into the #ifdef'd code block that
uses it.  Prevents a warning from gcc 3.2.
2002-04-09 00:52:05 +00:00
christos e6ab6d48dc PR/16174: Matthias Buelow: Job control fails on jobs that fd == 2 does not
point to a tty.

Unfortunately the shell assumed that it could do all process group
handling ioctls to fd=2, but this is not correct. Jobs that redirected
fd=2 would be unable to perform the ioctls and silently fail since
the error reporting channel is fd=2... Instead open /dev/tty set
it to close on exec, and use that instead (like all other shells
do). We don't handle the case where the OS does not provide FD_CLOEXEC
or FIOCLEX, because I am lazy.

While I am there:
- Simplify the code by defining functions for tc{g,s}pgrp when OLD_TTY_DRIVER
  is defined.
- make sure that 'sh &' works by stopping itself. Don't kill the shell's
  process group, kill the shell itself.
2002-04-03 14:30:44 +00:00
christos c910c75b83 PR/16010: Andreas Gustafsson: wait is not interruptible. 2002-03-22 19:50:42 +00:00
simonb 668ba50fa3 In forkshell() don't free the current job. Fixes problem with previous
commit where pipeline commands didn't inherit the correct process group.
Reviewed by Christos.

Change a trace format string arg to use %p instead of %x and a long cast.
2002-03-12 03:45:02 +00:00
christos bac9369a06 PR/15877: Ed Ravin: make sure that we cleanup enough of the job structure,
in jobfree() so that we don't fail when we use a malloc where free() trashes
freed memory.
2002-03-12 00:44:16 +00:00
christos ccbeeb7cba get rid of sp completely, we were free-ing a bogus pointer; found by simonb. 2002-03-12 00:14:31 +00:00
lukem b799ed2973 first variable argument to "read" is not optional 2002-02-24 21:41:52 +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 06ea4006cb PR/11542: Back-out previous change that caused
set -e
for x in a; do
    BAR="foo"
    false && echo true
    echo mumble
done

not to echo mumble...
2002-02-14 21:51:41 +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 39d26b8867 Add a commented out -DDEBUG in CPPFLAGS. 2002-02-11 18:55:10 +00:00
christos 4398551708 Fix off by one in the display of var trees. 2002-02-11 18:54:30 +00:00
ross dc5571b22e Generate <>& symbolically. I'm avoiding .../dist/... directories for now. 2002-02-08 01:21:55 +00:00
lukem 9c2af9970a .ifdef SMALLPROG, -DSMALL 2002-02-07 06:25:07 +00:00
wiz 5739c48f68 Punctuation nits, drop unnecessary .Pps, sort sections. 2001-12-20 20:07:40 +00:00
wiz 9f4702dcef Punctuation nit. 2001-12-20 20:06:45 +00:00
wiz 3ebcdc5e43 Whitespace nits. 2001-12-20 19:31:48 +00:00
he ed00fe0aee Plug a memory leak when setting PWD -- don't mark the variable with
VTEXTFIXED because the value is dynamically allocated.  Fix from
Tor Egge, FreeBSD PR#31533.
2001-11-14 18:04:36 +00:00