Commit Graph

392 Commits

Author SHA1 Message Date
hubertf
1cb54f68ac Add 'RETURN VALUE' section header. 2000-08-28 02:11:04 +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
cgd
96df053cba host program portability: set infp to stdin at runtime, since apparently
some systems (e.g. linux) define stdin in such a way that it can't
be used to initialize values at compile time.
2000-07-27 04:06:49 +00:00
cgd
28728fd305 host program portability: don't use <sys/cdefs.h>, __COPYRIGHT(),
__RCSID(), or __P().  (these programs have been de-__P()'d.)
Repeat after me: "Not all cross-compilation host systems are NetBSD."
2000-07-18 19:13:20 +00:00
jhawk
9d53f2aee6 Various mandoc updates to the Builtins
section; mostly .Ic, a few other nits.
2000-07-18 01:55:48 +00:00
jhawk
45a8e6b7e3 Note the meaning of 'trap 0' (execute on exit from shell) 2000-07-17 21:18:47 +00:00
matt
e2056eada9 include <stdlib.h>, <string.h>, or whatever as appropriate to shut up
gcc 2.96
2000-07-03 03:26:17 +00:00
elric
e6bccfe4be Back out previous vfork changes. 2000-05-22 10:18:46 +00:00
elric
f5dccf4728 When vforking ensure that the environment passed to exec is built before
vforking as a set of local variables which can be popped by the parent.

Addresses bin/10124.
2000-05-17 07:37:12 +00:00
elric
e8b0f2b813 INTON and FORCEINTON modify global variables, and so should not be
executed while we are vforked.
2000-05-15 03:42:48 +00:00
elric
c55fa30be8 Added includes for waitpid, sys/types.h and sys/wait.h. 2000-05-13 21:11:45 +00:00
elric
a0ef2ea948 In order to use __NetBSD_Version__, I needed to include sys/param.h. 2000-05-13 21:11:16 +00:00
elric
0eece24a3a Unused variable pgrp on line 576. 2000-05-13 20:59:41 +00:00
elric
4aeaa113a7 Quick fix.
jobs.h:91: warning: declaration of `vfork' shadows global declaration
2000-05-13 20:56:08 +00:00
elric
756a2ca1bd Now we use vfork(2) instead of fork(2) when we can. 2000-05-13 20:50:14 +00:00
simonb
d2f6a4723d Include <errno.h> instead of using "extern int errno;". 2000-04-14 05:54:20 +00:00
simonb
51ee9dc68d Don't declare 'extern opt*' getopt variables. 2000-04-14 05:52:56 +00:00
christos
b252543484 PR/9847: Geoff C. Wing: Make test(1) a builtin. 2000-04-09 23:27:03 +00:00
soren
1594850f00 Fix doubled 'the' in comment. 2000-03-13 22:46:59 +00:00
christos
9fcfbaea4d Fix problem where commands that caused exitstatus != 0 inside loops did
not cause the shell to exit when -e was set.
2000-02-09 20:26:53 +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
hubertf
a8bbeb8a4b Add under which conditions the "read" builtin returns success/failure.
Suggested in PR 8813 by Eric Mumpower <nocturne@arepa.com>
1999-11-16 22:03:25 +00:00
mrg
1b23e7d142 back out previous; it causes /etc/rc to break on my alpha and other lossage as reported in PR#8614 1999-10-13 00:59:10 +00:00
pk
ef45922abf Backtrack `exitstatus' to make the shell really ignore the status
of `tested commands' as in this example:

	set -e
	true; false && echo "not reached"
1999-10-10 21:22:24 +00:00
pk
8c06f48e15 Sprinkle some `const's in DEBUG bracketed code. 1999-10-08 21:10:44 +00:00
bouyer
d406538de6 xref sysctl(8) (for proc.<pid>.rlimits) 1999-09-28 14:54:41 +00:00
mjl
4c5c12b3f0 Mention -c option to sh(1), noticed by Matthew Aldous in PR/8499. 1999-09-27 19:34:25 +00:00
mycroft
2806df576c It turns out that the code disabled in revision 1.30 *does* have an important
function (which nobody was able to explain): it's critical to allowing a
complex command run from an interactive shell to be terminated.  So, reinstate
it and fix it correctly.  See the comment if you really want the gory details.
1999-08-31 08:58:47 +00:00
christos
3d42469030 compile with WARNS = 2 1999-07-09 03:05:49 +00:00
christos
f914977fae add -q in the synopsis line 1999-07-06 14:01:01 +00:00
christos
02048e84df PR/7814: Matthias Scheler: shell does not fork for builtins in backquotes,
leading to unexpected behaviour. Disable the no-fork optimization for now.
We need to revisit this and keep enough state around to recover from such
changes.
1999-06-26 16:31:47 +00:00
he
e97b0193be Fix for bin/7502, from Tor Egge / FreeBSD. Their commit message:
> During variable expansion, the internal representation of the expression
> might be relocated.  Handle this case.
1999-04-30 17:54:17 +00:00
he
4e69294c60 Correct a rather obvious typo (once Tor Egge pointed it out to me)
in the last change.
1999-04-06 21:05:27 +00:00
mycroft
2e23138ad7 If we exit due to a SIGINT, do it with raise() so that the wait status is
correct in the parent.
1999-04-05 15:00:28 +00:00
mycroft
c06643b836 Disable bogus-looking code that cause us to throw away SIGINTs. 1999-04-05 14:59:35 +00:00
christos
832949b912 When we execute commands from a shell script, make sure that the signals
are being caught (reported by Alexis Rosen), similar to the -c case.

#!/bin/sh
vi "$@"

^C when the script is running...
1999-03-27 13:46:19 +00:00
christos
28607542af PR/7231: Havard Eidnes: Shell quoting/trimming problem 1999-03-26 15:49:34 +00:00
ross
4b1d9297dc Make the `...' actually appear in the case/esac syntax section.
Fix a space botch in the $@ example.
Kill warnings caused by the effective but wrong use of \[ and \] to
perform the function of \&[ and \&].
1999-03-23 02:29:29 +00:00
garbled
f124765044 More and more .Os cleanups. .Os is defined in the tmac.doc-common file,
so we shouldn't override it with versions in the manpages.  Many more to
come.
1999-03-22 18:25:43 +00:00
castor
dc67d78474 Add '#include <sys/types.h>' since that's where int8_t and u_int8_t can
usually be found.
1999-03-08 17:55:20 +00:00
wrstuden
6790f70d78 Make cross-building from i386 to powerpc (from signed to unsigned char)
ports work right.
1999-02-23 01:50:26 +00:00
christos
96a46ed7b1 Fix off-by-one error in the starting point to search for an arithmetic
expression.
1999-02-06 17:23:09 +00:00
tron
96dc868859 Remove "arith.h" while cleaning. 1999-02-05 22:19:47 +00:00
christos
1666f88d5d Fix the -c problem differently. We cannot just ignore SIGINT etc, otherwise
we cannot interrupt sh -c <command>
1999-02-05 21:21:27 +00:00
christos
b4c9a78425 PR/5577: Craig M. Chase: sh does not build with PARALLEL set.
- Added YHEADER in Makefile, removed arith.h and adjusted the sources.
1999-02-05 07:52:51 +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
christos
dd65252560 PR/1788: Shinya Taniguchi: sh -c does not setup signals properly.
[Reminded to me by Alexis Rosen -- thx!]
1999-02-04 11:20:40 +00:00
cjs
9063efaca0 Add -q option, which when used with -v and/or -x, turns off the tracing
during the execution of /etc/profile, .profile and $ENV.
1999-02-04 00:27:07 +00:00
itohy
362c3e31c9 The builtin . (dot) command no longer sees the current working directory
even if the specified file is not in the PATH.
This change enforces security and makes it conform to POSIX.

Closes PR #6794.
I thought Christos committed this but not appeared yet. :)

The setstackmark()/popstackmark() pair in dotcmd(), used for freeing
stack storage possibly allocated by find_dot_file(), is redundant for now
since dotcmd() is surrounded by another pair in evalcommand().
This redundancy, however, may help future modifications
(suggested by Christos).
1999-02-02 15:49:52 +00:00
kleink
f71d010d24 Add support for the export and readonly -p option. 1999-01-28 18:11:50 +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
christos
e1849b79b1 PR/6213: Urban Boquist: /bin/sh does not handle a trapped signal correctly
The problem was that system calls got restarted after a signal,
	 instead of returning EINTR. Thus the read builtin, had no way to
	 know that a signal occured that could change the course of execution.
	 Since the code has sprinkled checks for EINTR all over the place,
	 it is supposed to work properly with non restartable syscalls.
	 The fix is to use siginterrupt(signo, 1), before setting a signal
	 handler, to make sure that system calls don't get restarted.
1999-01-18 16:18:04 +00:00
garbled
f33f4be925 Massive fixup:
Rewrite man page in mandoc format rather than nasty man format.
Fix a ton of parsing errors, and generate proper .Xr's.
document all known environment variables.
suggest ksh rather than bash.

The last two fix PR #1966.  Wheee!

Somebody with access to the POSIX spec needs to go in here, and document
our adherence, or lack thereof.
1999-01-11 19:34:53 +00:00
msaitoh
576a5fdc92 fix some bugs 1998-11-17 14:16:32 +00:00
garbled
b4e6f9c37a Modify to better document getopts. This fixes PR# 704. Much thanks to
Christos for helping me out with this.
1998-10-29 23:23:36 +00:00
ross
7fc1302b5d The recent cross-compile changes broke the build of x_sh. Properly use
${.IMPSRC} instead of the broken ${.CURDIR}/thing.c.
1998-10-08 00:29:38 +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
christos
26e51b35ac include <stdlib.h> to get the prototype for free() 1998-09-26 19:28:12 +00:00
itohy
cc484b787f The return value of setmode(3) is a pointer to malloc()'ed area
and must be freed to avoid memory leaks if called repeatedly.
The leaks occured on symbolic umask command, such as "umask go-w",
which is undocumented.
1998-09-24 17:49:48 +00:00
wrstuden
1037acbf7e We don't generate .o's anymore for helper programs, so don't CLEANFILES them. 1998-09-12 18:58:41 +00:00
wrstuden
d10063d5c7 Patch to make sh cross-compile right. mksyntax reports unsigned char for
powerpc, and signed for m68k & i386.
1998-09-12 18:55:07 +00:00
mycroft
ee9e50eacb Be more retentive about use of NOTREACHED and noreturn. 1998-07-28 11:41:40 +00:00
mycroft
9dc385beb1 Delint. 1998-07-28 05:31:22 +00:00
christos
d06f150426 PR/5848: David Holland: Use PIPE_BUF instead of hardcoding 4k 1998-07-27 17:12:45 +00:00
mycroft
5dd823ab5d const poisoning. 1998-07-26 19:44:12 +00:00
ross
69228f8bd8 Small edit to n1>&n2 description. 1998-07-04 06:52:07 +00:00
ross
ac875dda03 Fix a set of bugs where a cd of a relative pathname or a cd through a
symbolic link would not set PWD.
1998-05-21 16:50:40 +00:00
christos
efee39278b Simplify interface for general use. 1998-05-20 01:36:14 +00:00
christos
f792cdd756 Cast is*() args to unsigned chars in case the ctype macros are implemented
using arrays.
1998-05-20 00:32:05 +00:00
christos
96133865eb cast pid's to longs for OS's where this is the case. 1998-05-20 00:31:11 +00:00
christos
338ea4cec8 fix bug where if moving in history during a multi-line event, the
append to history event would end up in the last event where the history
was moved to instead of the multi-line event; reported by Mycroft
1998-05-20 00:29:26 +00:00
christos
3d8b8b2ed2 Fix dangling else warning. 1998-05-20 00:27:56 +00:00
christos
3ebdac1759 Portability fixes for a non flex based lexical analyzer. 1998-05-18 22:50:20 +00:00
christos
c6e03280d4 Need stdlib.h 1998-05-18 22:48:53 +00:00
christos
d2ded939ef PR/5315: Dan Winship: options parsing code should print errors to stderr. 1998-05-02 18:04:09 +00:00
cgd
2072394059 move OBJS depenency on built headers to after include of bsd.prog.mk, so
that things are built in the right order on 'make cleandir && make' (i.e.
so that the headers are properly built).
1998-04-19 05:22:08 +00:00
lukem
d6c354cb4b * remove CFLAGS+=-w for powerpc (added in 1.26):
- it was in the wrong place
	- makefiles shouldn't override CFLAGS; only CPPFLAGS and COPTS
	- christos fixed unsigned char stuff in 1.33 which should
	  remove the need for -w anyway
* move .include <bsd.prog.mk> to EOF
1998-04-13 12:06:48 +00:00
tv
482063559a .y.c <sys.mk> rule fixes. Don't create a y.tab.h file unless asked for,
and use smarter creation of the header file.
1998-04-09 00:32:31 +00:00
fair
667e4d4cd1 fix default PATH to be <paths.h> _PATH_DEFPATH 1998-04-07 21:15:33 +00:00
fair
618cca243b Change a few things to reference /usr/include/paths.h instead of local
references. Fixing the default PATH is a bit more effort.
1998-04-07 10:16:04 +00:00
veego
7f307512f9 Another try to make this work again. Lets hope that the we don't need a 4th
fix for it.
1998-03-30 12:06:48 +00:00
mrg
6e35073fed make this work again when . is not in $PATH 1998-03-30 10:07:16 +00:00
christos
0328c41456 Pr/5221: Jason Thorpe: Simplify sh Makefile, so that builts from other
directories work.
1998-03-29 09:27: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
04784d87fa Fix the VSTRIMRIGHT* bugs... The problem was not the string length computation,
but lack of '\0' termination. Factor this segment out as common code too, while
I am there.
1998-03-23 18:21:02 +00:00
christos
19e7771baa off by one error in ${%%} 1998-03-10 19:11:07 +00:00
christos
7cfc52b208 PR/5001: Tom Yu: cd ./ does not work. 1998-02-17 02:57:16 +00:00
christos
ce0d4f06a6 Previous fix broke $var quoting. Try again differently :-) 1998-02-17 00:16:16 +00:00
christos
d8a1d3710c Re-enabled EXP_RECORD 1998-02-05 08:34:49 +00:00
christos
f7c8df6d68 Fix bug introduced by EXP_RECORD, where in case there was a variable expansion
involved in the `for' list, the list was recorded twice, leading to incorrect
argument expansion.
Introduce ifsfree() function that free's the IFS region list, GC'ing duplicated
code.
1998-02-05 08:32:00 +00:00
thorpej
b65b5cae9e Sigh, have to cast pointer diffs to long. 1998-02-04 23:49:25 +00:00
thorpej
a40a144d00 Fix printf formats so they work on the Alpha. 1998-02-04 20:10:16 +00:00
mikel
a235399817 back out last change until christos fixes EXP_RECORD; PR 4932 1998-02-04 06:25:55 +00:00
christos
5a36c00160 PR/4851: Benjamin Lorenz: In the "for <var> in <args>" construct <args>
was not marked as a region to be handled by ifsbreakup. Add EXP_RECORD
to indicate that the argument string needs to be recorded.
1998-01-31 12:45:06 +00:00
christos
2b259b0600 - Add gcc attributes to printf like functions
- Fix format strings to be const
- Fix buffer length to be size_t
- Add %p format
- Avoid code duplication in varargs/stdarg cases
1998-01-31 12:37:55 +00:00
christos
7faabd5800 Include our local includes after the system's ones. 1998-01-31 12:36:16 +00:00
christos
71868e12e2 Fix printf format. 1998-01-31 12:34:12 +00:00
christos
e3f5fb922f BSD4_4 is a standard symbol in <sys/param.h>; make sure that files
that need this defined, include <sys/param.h> and don't define it in
the Makefile. Add a comment to that effect.
1998-01-21 10:47:37 +00:00
pk
5d9692a740 Define BSD4_4: quad_t's in struct rlimit; 1998-01-20 22:43:34 +00:00
christos
38c84eeda3 test for the boundary condition in the previous trailing blank fix 1998-01-16 16:26:22 +00:00