Commit Graph

327 Commits

Author SHA1 Message Date
David E. O'Brien
2749b14129 Consistently use FBSDID 2002-06-30 05:15:05 +00:00
Sheldon Hearn
62df9b6286 Document addition of RLIMIT_VMEM support, added in rev 1.26 of miscbltin.c. 2002-06-27 16:56:45 +00:00
Matthew Dillon
085b9f3eb2 Add support for RLIMIT_VMEM. The #ifdef's were already there but getopt()
needed to be adjusted.
2002-06-26 00:29:53 +00:00
Juli Mallett
4e17884ffe Remove two unused variables. 2002-06-20 05:21:43 +00:00
Juli Mallett
8b7808bc49 Minor const cleanup.
Don't discard qualifiers we don't need to discard.
2002-06-20 05:20:50 +00:00
Tim J. Robbins
029c8ee4fa Bring documentation on CDPATH and its effects on cd(1) back into sync with
reality (and POSIX): current directory isn't searched unless CDPATH has
a "." element or is unset.

PR:		38442
Submitted by:	oleg dashevskii <be9@be9.ru>
MFC after:	1 week
2002-06-19 12:04:22 +00:00
Tim J. Robbins
83952a118b Don't list shell builtins when the hash command is used (SUSv3) 2002-06-13 07:50:50 +00:00
Tim J. Robbins
8b34ad92a2 Document the -f and -v options of the unset builtin. 2002-06-06 04:12:50 +00:00
Tim J. Robbins
592588448e Quote the output of the no-argument form of the `set' builtin for re-input
to the shell.
2002-06-06 04:02:50 +00:00
Tim J. Robbins
45086f8cf6 Add the SUSv3 -p ("portable") option to both the export and readonly
builtins. This makes export/readonly print lines in the form
"export name=value".
2002-06-06 03:57:22 +00:00
Tim J. Robbins
dee75cf75d Don't modify output that is to be quoted if it contains no IFS characters
or shell metacharacters.
2002-06-06 03:29:23 +00:00
Tim J. Robbins
5b96a60711 Display job status correctly when a pipeline is suspended. 2002-06-04 15:26:00 +00:00
Tim J. Robbins
5179c2f25f Describe finished jobs as "Done", not "Exit" (SUSv3) 2002-06-04 14:40:33 +00:00
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