Commit Graph

364 Commits

Author SHA1 Message Date
Tim J. Robbins
cb1a4fb419 Don't output state' and current' fields for processes that aren't
leaders in -l option to jobs(1).
2002-06-04 14:37:13 +00:00
Tim J. Robbins
d982b3a5f6 Missing prototypes from previous commit. 2002-06-04 13:13:54 +00:00
Tim J. Robbins
41d09fe083 Correct minor spacing problem in output of jobs -l for pipelines. 2002-06-04 13:01:51 +00:00
Tim J. Robbins
e5341cbb17 Quote alias values in the output of the alias(1) builtin so they are
suitable for re-input to the shell (SUSv3)
2002-06-04 12:59:12 +00:00
Tim J. Robbins
ee6712f2f9 Fix typo causing ``fc -e'' to not work correctly. getopt() sets optarg,
not shoptarg.
2002-06-02 08:34:09 +00:00
Tim J. Robbins
32c077867c Adding an entry to the history with H_ENTER moves libedit's internal
history cursor. Reset the cursor after adding the entry to the history
when doing ``fc -s'' so the output is correct.
2002-06-02 08:27:04 +00:00
Tim J. Robbins
39dccc6f6d Implement $PPID, the parent process ID of the shell. 2002-06-01 02:14:48 +00:00
Tim J. Robbins
f63d6dbfc9 Support the remaining job ID formats required by SUSv3:
%+ (current job, same as %%),
%- (previous job),
%?str (job with "str" in its command name).
2002-06-01 01:51:42 +00:00
Tim J. Robbins
ad8a075902 Add -s (output PID's only) and -l (show PID's) options to the jobs(1)
builtin. Modify the output format to match what SUSv3 requires.
2002-05-31 14:04:23 +00:00
Tim J. Robbins
bdfc15df5e #if JOBS around a job control-related statement to allow compilation with
job control disabled.
2002-05-31 13:10:38 +00:00
Tim J. Robbins
e3f3094912 Break the code to display status info for one job out from showjobs() into
showjob(), use it inside dowait() to display status info for consistency,
and in a format closer to what the standard requires.
2002-05-31 13:07:05 +00:00
Tim J. Robbins
3771ef59ae Move job to front of most recently used job list when bg'd or fg'd. 2002-05-31 12:35:34 +00:00
Tim J. Robbins
d86825beb8 Instead of keeping just the jobid of the most recently bg'd or fg'd job,
keep a linked list of the jobs, most recently used first. This is required
to support the idea of `previous job', and to allow the jobs fg and bg
default to be correct according to POSIX.
2002-05-31 12:31:23 +00:00
Ruslan Ermilov
81e9cda2c9 mdoc(7) police: tidy up the markup a bit. 2002-05-29 15:38:59 +00:00
Tim J. Robbins
fc482908be sh appeared in Version 1, not System V.1. 2002-05-25 12:18:27 +00:00
Tim J. Robbins
d513af6a66 Implement `set +o', which displays the currently set options in a format
suitable for re-input into the shell.
2002-05-25 12:11:58 +00:00
Tim J. Robbins
09086b0499 Bring back the cd -L and -P options from revision 1.24, but try harder not
to fail when the logical current directory no longer exists. Allow changes
to absolute paths when logical cwd is invalid, fall back to physical cd
if logical cd fails.
2002-05-22 05:15:53 +00:00
Tim J. Robbins
baf3e7c14b Temporarily back out revision 1.24; it seems to handle the case where the
current directory no longer exists incorrectly and breaks `make cleandir'.
2002-05-22 03:29:20 +00:00
Tim J. Robbins
178897f127 Add the SUSv3 -L and -P options to the cd and pwd builtin utilities. `Logical'
handling of .. is now the default.
2002-05-20 07:54:39 +00:00
Juli Mallett
9e3bfadea8 Remove a small, annoying, nit I ran in to editing this file, a lone tab
on a line by itself.
2002-05-19 17:50:23 +00:00
Tim J. Robbins
1b5a48ff88 Implement the -u (-o nounset) option, which gives an error message if
an unset variable is expanded.

Obtained from:	NetBSD (bjh21, christos)
2002-05-19 08:30:16 +00:00
Tim J. Robbins
addcdbb29f Make the fg and bg commands give the output required by SUSv3.
fg outputs the name of the command, bg outputs the name of the command
and the job id.
2002-05-19 07:27:26 +00:00
Tim J. Robbins
1a958c6653 Implement the -C (-o noclobber) option, which prevents existing regular
files from being overwritten by shell redirection.
2002-05-19 06:03:05 +00:00
Tom Rhodes
ebd4324457 Consistancy check s/file system/filesystem/
Reviewed by:	brian
2002-05-16 01:57:20 +00:00
Dag-Erling Smørgrav
d397408818 Usage style sweep: spell "usage" with a small 'u'.
Also change one case of blatant __progname abuse (several more remain)
This commit does not touch anything in src/{contrib,crypto,gnu}/.
2002-04-22 13:44:47 +00:00
Philippe Charnier
e004acc891 Use `The .Nm utility' 2002-04-16 20:08:06 +00:00
George C A Reid
4c7e4a544a Stop a null pointer dereference in the builtin hash function.
PR:		36141
Approved by:	cracauer
MFC after:	1 week
2002-04-15 15:49:30 +00:00
Warner Losh
1a24391866 Remove now-obsolete __STDC__ ifdefs, remove redundant NULL definition and
include stdlib.h for NULL.
2002-02-18 06:08:23 +00:00
Kris Kennaway
afe781faa2 Lock down with WFORMAT=1 except those directories with unfixed warnings.
Tested on i386 and alpha.
2002-02-04 02:49:19 +00:00
Warner Losh
90e41fc40a %.* takes an int, not a size_t. 2002-02-02 07:06:58 +00:00
Warner Losh
5134c3f799 o __P has been reoved
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)
	{
	...
2002-02-02 06:50:57 +00:00
Sergey Babkin
63f901ef53 The fix for >/dev/stdout, including Tor Egge's fix for the bug in the
original attempt of the fix. And yes, this time I've tried to build
world with it and it succeeded.

Submitted by:	Tor Egge
MFC after: 1 week
2002-01-13 14:37:40 +00:00
Alfred Perlstein
8f5c93f79f backout rev 1.14, it's breaking things. 2001-12-24 22:27:04 +00:00
Sergey Babkin
41f1be05da Added ability to do ">/dev/stdout". The apsfilter people are anxious
to get it MFCed in time for release 4.5.

MFC after: 2 weeks
2001-12-22 02:40:58 +00:00
David E. O'Brien
a748290789 Default to WARNS=2. Binary builds that cannot handle this must explicitly
set WARNS=0.

Reviewed by:	mike
2001-12-04 01:57:47 +00:00
Akinori MUSHA
018d9f6237 Remove the printf builtin command from sh(1), which command is not
used so often that it's worth keeping it as a builtin.

Now that all the printf invocations from within the system startup
scripts, we can safely remove it.

Urged by:	sheldonh  :)

No MFC is planned so far because it may break compatibility and
violate POLA.
2001-11-20 18:33:59 +00:00
Akinori MUSHA
d90c5c4ab4 Make test(1) a builtin command of our sh(1) for efficiency. The
binary size increase is 3,784 bytes (about 0.6%).

I don't drop the printf builtin while I'm here because some /etc/rc.*
scripts seem to use it before mounting /usr where printf(1) resides.

Reviewed by:	arch (sheldonh)
Inspired by:	NetBSD, ksh
Clued by:	ume (on how the printf builtin is used)
2001-11-17 19:10:11 +00:00
Tor Egge
f14c1c47f9 Don't call setvar() with the VTEXTFIXED flag. A copy is created by
setvar() and passed to setvareq(). When the VTEXTFIXED flag is set,
that copy is never freed, causing a memory leak.

PR:		31533
Submitted by:	maxim@macomnet.ru
2001-11-07 23:00:05 +00:00
Tor Egge
c4c8394066 Repair normally unused is_digit() macro. 2001-10-14 21:11:33 +00:00
David E. O'Brien
757eeda04b *** empty log message *** 2001-10-01 08:43:58 +00:00
Tor Egge
d2653b8806 Don't check uninitialized memory for having the shell control character
value CTLARI since this might break expansion of arithmetic expressions.

Don't access memory below start of stackblock.

Problem analyzed by hunt@iprg.nokia.com, slightly different patch applied.

PR:		24443
Submitted by:	hunt@iprg.nokia.com
2001-09-19 20:16:38 +00:00
Tor Egge
0c4eedda7b BASESYNTAX, DQSYNTAX, SQSYNTAX and ARISYNTAX handles negative indexes.
Allow those to be used to properly quote characters in the shell
control character range.
2001-09-19 20:07:47 +00:00
Tor Egge
5f2359b374 Adjust some type checks to include CTLQUOTEMARK in the range of
shell control characters.
2001-09-19 19:58:09 +00:00
Peter Wemm
ef15bfc59f Initialize infp at main() 2001-08-13 21:55:04 +00:00
Ruslan Ermilov
8af1452cf8 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
Sheldon Hearn
42abf713c9 can not -> cannot 2001-08-08 18:32:06 +00:00
Ruslan Ermilov
c4d9468ea0 mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text.
Not only this slows down the mdoc(7) processing significantly, but it also
has an undesired (in this case) effect of disabling hyphenation within the
entire enclosed block.
2001-08-07 15:48:51 +00:00
Sheldon Hearn
e1b4d8d074 Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The
definitions are more readable, and it's possible that they're
more portable to pathalogical platforms.

Submitted by:   David Hill <david@phobia.ms>
2001-07-26 11:02:39 +00:00
Sheldon Hearn
71337c33bd Break the list of parameter expansions into two lists so that
the paragraph introducing the prefix and suffix pattern expansions
does not appear as part of the explanation for the string length
expansion.
2001-07-23 10:18:05 +00:00
Dima Dorfman
7ebcc426ef Remove whitespace at EOL. 2001-07-15 07:53:42 +00:00
Ruslan Ermilov
caa2db3be9 mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 10:04:09 +00:00
Ruslan Ermilov
5521ff5a4d mdoc(7) police: sort SEE ALSO xrefs (sort -b -f +2 -3 +1 -2). 2001-07-06 16:46:48 +00:00
David Malone
b82561452f Use the correct printf format to print a long.
Approved by:	cracauer
2001-06-26 11:11:30 +00:00
Dima Dorfman
cafefe8c1b Include missing header files which define functions for which gcc has
builtins (e.g., exit, strcmp).
2001-06-24 23:04:23 +00:00
Dima Dorfman
a910f192bb Remove duplicate words. 2001-06-24 01:34:38 +00:00
Dag-Erling Smørgrav
26f6b0fbe8 Add more headers that are required with -fno-builtin (stdlib and strings) 2001-06-19 15:41:57 +00:00
Garance A Drosehn
0a315e79df Fix how /bin/sh handles 'for' and 'case' statements when it is called to do
errexit (-e) processing.  This solves a problem where 'make clean' would
fail with an unspecified error in certain automake-generated makefiles.

Reviewed by:	no objections from -hackers...
MFC after:	2 weeks
2001-06-01 00:07:09 +00:00
Warner Losh
92e331afed Use PATH_MAX in preference in MAXPATHLEN. 2001-05-30 03:37:28 +00:00
Dima Dorfman
9434a1c780 Document "chdir" builtin. 2001-04-28 02:13:58 +00:00
Kris Kennaway
a2e73040f4 -Wnon-const-format sweep: make format strings const char *'s, add
__printflike()/__printf0like() to function prototypes, as appropriate.

Reviewed by:	bde, -audit
2001-04-17 07:46:38 +00:00
Brian Somers
b785bd7d3b `|'' should be more binding than `!'' so that this isn't broken:
if ! echo bla | wc -c ; then
		echo broken
	fi

Obtained from: NetBSD
2001-04-09 12:46:19 +00:00
Brian Somers
6c0bde79a8 A much better (more correct) fix for handling ``!'' characters
Obtained from: NetBSD
2001-04-04 10:11:43 +00:00
Brian Somers
51a9b1c281 Handle ``!'' characters when they appear as second and subsequent
parts of an && or || expression.

This makes this expression work as expected:

	if true && ! false; then echo yes; fi
2001-04-04 09:30:50 +00:00
Martin Cracauer
adce2a1b4b Fix child's SIGSTOP behaviour in scripts.
When a child is receiving SIGSTOP, eval continues with the next
command.  While that is correct for the interactive case (Control-Z
and you get the prompt back), it is wrong for a shellscript, which
just continues with the next command, never again waiting for the
stopped child.  Noted when childs from cronjobs were stopped, just to
make more processes (by wosch).

The fix is not to return from a job wait when the wait returned for a
stopped child while in non-interactive mode.  This bahaviour seems to
be what bash2 and ksh implement.  I tested for correct behaviour for
finnaly killing the child with and without forgrounding it first.
When not foregrouding before killing, the shell continues with the
script, which is what the other shells do as well.

Reviewed by:	Silence on -current
2001-02-06 10:29:34 +00:00
Ruslan Ermilov
d0353b836e mdoc(7) police: split punctuation characters + misc fixes. 2001-02-01 16:38:02 +00:00
Ruslan Ermilov
32f6256a49 Prepare for mdoc(7)NG. 2001-01-16 09:08:22 +00:00
Ruslan Ermilov
1586940ea5 Prepare for mdoc(7)NG. 2000-12-18 14:48:17 +00:00
Ruslan Ermilov
12e720d78b Prepare for mdoc(7)NG. 2000-12-15 17:37:31 +00:00
David E. O'Brien
1a37aa566b Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.
2000-12-09 09:35:55 +00:00
Ruslan Ermilov
b4f0f4aa81 mdoc(7) police: Er macro usage cleanup. 2000-11-22 15:55:01 +00:00
Kris Kennaway
c8b46b3ee3 Use secure temporary filenames during build.
Audited by:	markm, cracauer
2000-11-22 11:05:51 +00:00
Brian Somers
4682f420f2 Implement the <> redirection operator. 2000-10-03 23:13:14 +00:00
Martin Cracauer
b5803eae6a Disable part of my 8-bits fixes from December 1999.
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>
2000-08-16 12:23:57 +00:00
Martin Cracauer
d753a42598 Fix type builtin for absolute paths and relative paths with directory
names in them.

Also use a colon in the answer of `type` everytime the questioned item
is not usable.

PR:		bin/20567
2000-08-16 12:08:02 +00:00
Martin Cracauer
84c3800cdc From submitter:
growstackblock() sometimes relocates a stack_block considered empty
without properly relocating stack marks referencing that block.
The first call to popstackmark() with the unrelocated stack mark
as argument then causes sh to abort.

Relocating the relevant stack marks seems to solve this problem.

The patch changes the semantics of popstackmark() somewhat.  It can
only be called once after a call to setstackmark(), thus cmdloop() in
main.c needs an extra call to setstackmark().

PR:		bin/19983
Submitted by:	Tor.Egge@fast.no
Reviewed by:	Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
2000-08-16 10:39:43 +00:00
Sheldon Hearn
1b9735e6f2 Mark up the -a flag to unalias as a flag (Fl), not an argument (Ar). 2000-07-24 15:02:04 +00:00
Sheldon Hearn
5d3b843b57 Add missing punctuation to one line. 2000-07-24 14:59:50 +00:00
Mark Ovens
501e74b7ca Document the builtin echo command
Reviewed by:	Matthew Hunt <mph@astro.caltech.edu>
2000-07-17 23:37:55 +00:00
SADA Kenji
410fb0acaa Fixd with alias missing.
PR:		bin/19475
Approved by:	Martin Cracauer <cracauer@cons.org> (with conditions)
2000-07-15 14:34:37 +00:00
Matthew Hunt
a585d13451 Add \a and \e to "echo -e" escape handling. 2000-06-26 22:43:30 +00:00
Martin Cracauer
98e05fd3ef Fix parsing of string for eval command.
PR:		18447
Submitted by:	Koji Mori <mori@tri.asanuma.co.jp>
2000-05-15 13:02:07 +00:00
Martin Cracauer
b2acf8878e Fix environment passung to eval'ed commands.
PR:		bin/6577
Submitted by:	Anatoly Vorobey <mellon@pobox.com>
Approved by:	silence amoung other sh experts
2000-05-15 12:33:17 +00:00
Martin Cracauer
d62ec71c31 Rename the trace() function (that is build only in the -DDEBUG=2
case), so that it doesn't clash with the ncurses function of the same
name when linking statically with -ltermcap.

The linker only complains when -static is used, and it is not clear
whether this is a bug.

PR:		bin/18104
Submitted by:	Anatoly Vorobey <mellon@pobox.com>
2000-04-20 11:39:11 +00:00
Martin Cracauer
e988388eff Include <errno.h> when compiling with -DDEBUG=2
PR:		bin/18104
Submitted by:	mellon@pobox.com
2000-04-20 09:55:57 +00:00
Martin Cracauer
f01e3d0cfe Fix warnings, some of them serious because sh violated name
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.
2000-04-20 09:49:16 +00:00
Warner Losh
fba0ed115e Use #include <errno.h> rather than extern int errno;. 2000-04-14 06:03:39 +00:00
Martin Cracauer
c11e75cfcf Fix ${#varname} (getting length of string) when in double-quotes.
Approved-by:	jkh

PR:		bin/12137
Submitted by:	"Danny J. Zerkel" <dzerkel@columbus.rr.com>
2000-02-15 08:00:11 +00:00
Martin Cracauer
a436dc79f5 Fix command hash handling on
PATH=... command

Noted by and fix works for Marcel Moolenaar <marcel@scc.nl>
1999-12-20 13:42:59 +00:00
Martin Cracauer
2dde9ce37a Second part of 8-bit fixes. 1999-12-16 12:03:46 +00:00
Martin Cracauer
3652a236fa Document ulimit -b for RLIMIT_SBSIZE. 1999-12-15 16:12:32 +00:00
Martin Cracauer
73f612b50d First round of 8-bit fixes. 1999-12-15 11:46:32 +00:00
Martin Cracauer
671356079b make '|' character visible.
PR:		docs/15265
Submitted by:	takamune@avrl.mei.co.jp
1999-12-05 12:13:54 +00:00
Martin Cracauer
e92feeebb1 Fix "subscript has type `char'" warnings by casting to int, as
discussed on -arch.
1999-12-04 17:12:47 +00:00
Martin Cracauer
6c48b6cf75 Include strerror(errno) in error messages after failed system calls.
Fix a warning.
1999-11-29 19:11:01 +00:00
Sheldon Hearn
e918fc8f72 Follow-up on mdoc fixes in rev 1.35; this includes things that I missed
in that revision as well as things I broke in that revision.  A note-
worthy instance of the latter case was the inversion of -E and -V in the
subsection on Commandline Editing.
1999-11-18 08:13:21 +00:00
Martin Cracauer
6d9efc2432 The pipleline problem introduced in version 1.22 wasn't fully fixed in
1.23. This revision should work for long pipes both in
here-documents/backquote and in normal cases.

Fix works for jmz, bde.
1999-11-17 16:53:34 +00:00
Sheldon Hearn
150c3a33b9 Don't call bash(1) a Korn shell clone. Instead, use pdksh(1) as an
example of such a clone.

PR:		14601
Submitted by:	Matthias Buelow <mkb@altair.mayn.de>
1999-11-10 13:27:54 +00:00
Steve Price
6edf2a5be8 Correct logic from previous commit - middle processes in long pipes
don't have their stdin closed indisciminantly.

Reviewed by:	markm
1999-11-07 17:07:05 +00:00
Martin Cracauer
74eeb719fd When a backquote command inside a here-document had a pipe with more
than two processes (got that? :-), the stdin fd of the middle
processes that has just been set up was accidetially closed. Don't do
this.

PR:		bin/14527
1999-11-05 12:06:30 +00:00
Martin Cracauer
905f2e447b Fix ';' command when used with -e flag.
PR:		bin/14509
1999-10-26 13:17:18 +00:00
Brian Feldman
7cde774d15 Implement ulimit -b for RLIMIT_SBSIZE. 1999-10-09 20:56:06 +00:00
Sheldon Hearn
49e11e3a66 Mdoc cleanup, with a few grammar cleanups on the side.
Reviewed by:	mpp
1999-10-07 13:56:43 +00:00
Sheldon Hearn
e6d3cf2648 Correct some hard sentence breaks. Only those surrounding the previous
commit and those which cause ugly nroff output have been fixed, since
the purpose of the style guideline which they contravene is to reduce
the sizes of deltas.

Reported by:	bde
1999-09-14 11:46:04 +00:00
Sheldon Hearn
c644db6aa2 Improve shell documentation:
* Consistently misspell built-in as builtin.

* Add a builtin(1) manpage and create builtin(1) MLINKS for all shell
  builtin commands for which no standalone utility exists.  These MLINKS
  replace those that were created for csh(1).

* Add appropriate xrefs for builtin(1) to the csh(1) and sh(1) manpages,
  as well as to the manpages of standalone utilities which are supported
  as shell builtin commands in at least one of the shells. In such
  manpages, explain that similar functionality may be provided as a
  shell builtin command.

* Improve sh(1)'s description of the cd builtin command. Csh(1) already
  describes it adequately. Replace the cd(1) manpage with a builtin(1)
  MLINKS link.

* Clean up some mdoc problems: use Xr instead of literal "foo(n)"; use
  Ic instead of Xr for shell builtin commands.

* Undo English contractions.

Reviewed by:	mpp, rgrimes
1999-09-08 15:40:46 +00:00
Sheldon Hearn
ccbd308159 Revert to using .Xr for builtins. The cross-references don't work now,
but that doesn't mean that they will never work.

Requested by:	mpp, rgrimes
1999-08-31 12:44:52 +00:00
Sheldon Hearn
6b15476ec9 Clean-up:
Fix grammar and spelling nits.
	Use .Dq and .Qq where appropriate.
	Divorce trailing punctuation from quoted elements.
	Use .Dq instead of .Xr for builtins.
	Remove trailing whitespace and blank lines.

PR:	13340
1999-08-30 10:13:04 +00:00
Peter Wemm
2a4562393f $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
Thomas Gellekum
8f0561cc42 Make the behaviour of `read -e', ie. treating backslashes as special,
the default. Add -r option for the read builtin to reverse this.

PR:		13274
Reviewed by:	cpiazza, hoek, sheldonh
1999-08-26 08:16:27 +00:00
Sheldon Hearn
58aa6f74a2 Fix handling of the cd command inside evaluations. It was changing PWD,
which it should not do.

PR:	12578
Reported by:	Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
Submitted by:	Niall Smart <niall@pobox.com>
1999-07-19 11:00:33 +00:00
Kris Kennaway
46be34b902 Various spelling/formatting changes.
Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
1999-05-08 10:22:15 +00:00
Warner Losh
426e9c1dcc First set of fixes to keep egcs happy. These include {} around single
statement if blocks[*] when the else could be ambiguous, not defaulting
to int type and removal of some unused variables.

[*] This is explicitly allowed by style(9) when the single statement
spans more than one line.

Reviewed by: obrien, chuckr
1999-04-25 21:13:34 +00:00
Martin Cracauer
57b2932a14 Next approach to make loops in interactive interruptable.
PR:		bin/9173
1999-04-21 11:52:39 +00:00
Masafumi Max NAKANE
120ac26db8 Typo fix. 1999-04-19 18:48:26 +00:00
Martin Cracauer
466b673d7e Remove my temporary detection for PR 7059, Tor Egge fixed this bug.
PR:		7059
1999-04-13 12:43:55 +00:00
Tor Egge
c4e5a8a8b9 During variable expansion, the internal representation of the expression
might be relocated.  Handle this case.
PR:		7059
1999-04-13 04:13:09 +00:00
Martin Cracauer
4c1b08b3bb Fix typo in source-explaining comment. 1999-04-12 15:23:27 +00:00
Martin Cracauer
9d5efc1507 Add a guarded abort() for the problem in PR bin/7059 (no fix so far,
this is hairy).

Reformat this file to comply to style(9). It had mixed styles before.

PR:		bin/7059
1999-04-12 14:23:36 +00:00
Tor Egge
8b220a611d When a variable expansion is enclosed in double quotes, the internal
representation of the expression is quoted.  Take care of this when
doing pattern matching in conjunction with trimming.

	#!/bin/sh
	c=d:e; echo "${c%:e}"

PR:		NetBSD PR#7231
Noticed by:	Havard Eidnes <Havard.Eidnes@runit.sintef.no>
1999-04-09 15:23:48 +00:00
Martin Cracauer
4487495433 In interactive shells, break loops to the topmost level when a child
is killed by a signal.

(In non-interactive shells - that means a shellscript - the shell just
exits, this was already working)

PR:		bin/9173
1999-04-03 12:55:51 +00:00
Martin Cracauer
b8ec435e6b Implement -a flag. A test shell script can be found at
http://www.cons.org/cracauer/download/sh-interrupt/testsuite/test_export.sh
The PR also had test cases the new version passes.

Fix typo in comment.

PR:		bin/1030
1999-04-03 11:41:46 +00:00
Martin Cracauer
2870f7a83c -T was missing in the synopsis line.
Submitted by:	BDE
1999-04-02 09:28:00 +00:00
Martin Cracauer
c1c72a3c2a The immediate execution of traps I introduced in September 1998 (to
make /etc/rc interruptible in cases when programs hang with blocked
signals) isn't standard enough.

It is now switched off by default and a new switch -T enables it.

You should update /etc/rc to the version I'm about to commit in a few
minutes to keep it interruptible.
1999-04-01 13:27:36 +00:00
Brian Somers
71405fb6b3 sh doesn't support <> redirections.
PR:	7325
1999-03-31 21:02:01 +00:00
Joseph Koshy
c83e7c5041 Add references to test(1) and expr(1). 1998-12-18 03:51:18 +00:00
Warner Losh
a207266e91 Free memory from setmode.
Obtained from: OpenBSD
1998-12-16 04:45:35 +00:00
Bruce Evans
3b53d3803e Fixed warnx format errors in printf and csh, and snprintf format errors
in sh, by using separate macros for the 1, 2 and 3-arg calls to warnx.
(The 3-arg warnx macro in sh/bltin/bltin.h used to require bogus dummy
args.)
1998-12-07 12:14:04 +00:00
Bill Fumerola
0bd063bcd3 Fix typo. "If the an entry" --> "If an entry"
PR:		docs/8140
Submitted by:	Sue Blake <sue@vedanix.welearn.com.au>
1998-12-02 23:20:11 +00:00
Tor Egge
5557a02a60 Be more consistent with handling of quote mark control character.
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.
1998-09-13 19:24:57 +00:00
Martin Cracauer
9bbfa41541 Narrow down conditions to break wait() to process traps.
Improve comments.
1998-09-10 22:09:11 +00:00
Martin Cracauer
e6ac45dde2 Fix an inefficiency I introduced in my last commit.
Include "expand.h" vom memalloc.c to pull function declartion into scope
1998-09-10 14:51:06 +00:00
Martin Cracauer
135421ddbf If traps are set, they are now executed even when a signal-blocking
foreground child is running. Formerly, traps were exceuted after the
next child exit.

The enables the user to put a breaking wrapper around a blocking
application:
  (trap 'echo trap ; exit 1' 2; ./pestyblocker; echo -n)

The "echo -n" after the child call is needed to prevent sh from
optimizing the trap-executing shell away. I'm working on this.
1998-09-08 13:16:52 +00:00
Tor Egge
6f47734fd7 Better handling of word splitting. Don't record the same region
multiple times when performing nested variable expansion, and
preserve some quoting information in order to avoid removing
apparently empty expansion result.
1998-09-06 21:13:09 +00:00
Tor Egge
37f0a6708e Don't blindly eliminate `..' and the previous pathname component.
PR:		2541
Obtained from:	NetBSD
1998-09-06 21:01:57 +00:00
Martin Cracauer
1f40b47b46 Improve bookkeeping of in_waitcmd and style fixes.
Submitted by:	Bruce Evans
1998-08-25 09:33:34 +00:00
Martin Cracauer
40d009a717 Re-enable killing childs with SIGQUIT. Spotted by Bruce Evans. 1998-08-25 08:49:47 +00:00
Martin Cracauer
a1c7435ae3 Got two volatile sig_atomic_t and int mixed up. Spotted by Gary Palmer. 1998-08-24 19:15:48 +00:00
Martin Cracauer
7a8e920bb9 Do not exit on SIGINT in non-interactive shells, fixes PR 1206,
i.e. this makes emacs usable from system(3). Programs called from
shellscripts are now required to exit with proper signal status. That
means, they have to kill themself. Exiting with faked numerical exit
code is not sufficient.

Exit with proper signal status if script exits on signal.

Make the wait builtin interruptable, both with and without traps set.

Use volatile sig_atomic_t where (and only where) appropriate.

(Almost) fix printing of newlines on SIGINT.

Make traps setable from trap handlers. This is needed for shellscripts
that catch SIGINT for cleanup work but intend to exit on it, hance
have to kill themself from a trap handler. I.e. mkdep.

While I'm at it, make it -Wall clean. -Wall is not enabled in
Makefile, since vararg warnx() macro calls in usr.bin/printf/printf.c
are not -Wall-able.
PR:		1206
Obtained from:	Basic SIGINT fix from Bruce Evans
1998-08-24 10:20:37 +00:00
Joseph Koshy
fab2680594 Document behaviour of "-" and "--" on the command line.
PR: docs/5399
1998-07-30 04:47:56 +00:00
Bruce Evans
3c3472fb32 Added a `build-tools' target for internal tools.
Removed explicit dependencies of foo.o on foo.c.  These were mainly
placeholders for comments about missing dependencies of tools objects
on headers.  This problem needs to be handled more generally.
1998-07-07 01:06:58 +00:00
Philippe Charnier
3d7b5b9302 Add rcsid. Spelling. 1998-05-18 06:44:24 +00:00
Bruce Evans
3ef22d496d Backed out previous backout. Put y.tab.h back in SRCS. 1998-05-06 15:33:59 +00:00
Bruce Evans
e43e36af7d Backed out previous commit. It was tested, but not for the case where
a separate object tree doesn't exist.  Crufty makefiles will have to
put y.tab.h in SRCS so that we know not to create foo.h from foo.y.
1998-05-05 07:36:55 +00:00
Bruce Evans
b681d90662 Fixed races in `make -jN' using new yacc rules. 1998-05-04 20:09:06 +00:00
Martin Cracauer
686ed44763 When calling a shell function, remember whether exit status is tested.
This is needed for the '-e' option. See the PR for more details.
PR:		6047
Reviewed by:	PR submitter, silence on review request.
1998-05-04 07:24:10 +00:00
Bruce Evans
cddfa6c981 Backed out most of rev.1.19 (explicit dependencies of object files
on generated headers).  This is now handled generally in bsd.prog.mk.
1998-04-26 16:12:23 +00:00
John Polstra
6466945a67 Explicitly describe the rules the shell uses to search for a file
sourced by the "." command.
1998-02-12 01:23:11 +00:00
Martin Cracauer
8624242ab8 Back out my previous attempt to fix SIGINT/SIGTERM behaviour 1998-02-06 23:50:39 +00:00
Martin Cracauer
9dee16dba6 Fix handling of SIGINT/SIGQUIT for foreground subprocesses. Most
urgent need is when you run sh around a program that intentionally
uses SIGQUIT/SIGINT for asynchronous events, i.e. $EDITOR started from
system(2), like many mailers do. This fixes PR bin/1206 and possibly
bin/4241.

The solution committed has been tested for a large number of possible
cases (see recent discussion on cvs-committers). I completed a make
world, made sure 'make world' is interruptable and used the changed
/bin/sh as a login shell all day, including job control and using
SIGQUIT-catching programs (to write this message :-).

PR:		bin/1206
Reviewed by:	discussion on cvs-commiters
1998-02-06 18:14:26 +00:00
Steve Price
ee7dc4169c Correct a bogon in an example.
PR:		5415
Submitted by:	Sergei S. Laskavy <laskavy@pc759.cs.msu.su>
1998-01-02 19:23:05 +00:00
Alexander Langer
3344c3521c Added $Id$. 1997-12-29 00:00:10 +00:00