Commit Graph

2885 Commits

Author SHA1 Message Date
Xin LI
41f05c8281 Constify parameters, no functional or binary change.
Verified with:	sha256(1)
MFC after:	2 weeks
2013-05-15 18:38:28 +00:00
Joel Dahl
2710751bc3 mdoc sweep. 2013-05-12 22:22:12 +00:00
Jilles Tjoelker
336e0c87fa sh: Remove linked list of stack marks.
The linked list of stack marks may cause problems if the allocation stack is
used between an exception and a higher-level popstackmark(), as it may then
touch a stack mark that is local to a function which has returned.

Also, the adjustment compares to a pointer passed to realloc(), which is
undefined behaviour.

Instead of adjusting stack marks when reallocating stack blocks, ensure that
such an adjustment is never necessary by fixing a small piece of memory in
place at a stack mark. This also simplifies the code.

To avoid the problems reported in bin/175922, it remains necessary to call
setstackmark() after popstackmark() if the stack mark remains in use.
2013-05-11 20:51:00 +00:00
Eitan Adler
4ac1163902 Make dd's signal handler async safe.
PR:		bin/75258
Submitted by:	"Oleg V. Nauman" <oleg@reis.zp.ua>
Arrival Date:	Sun Dec 19 14:50:21 GMT 2004
Reviewed by:	mjg, jhb
Reviewed by:	jilles (earlier version)
MFC after:	1 week
2013-05-10 18:43:36 +00:00
Eitan Adler
6c7d832824 Fix two typos
Reviewed by:	jilles
2013-05-09 21:29:16 +00:00
Jilles Tjoelker
5aa6dfda1c sh: Use O_CLOEXEC and F_DUPFD_CLOEXEC instead of separate fcntl() call. 2013-05-05 10:51:40 +00:00
Jilles Tjoelker
c4539460e3 sh: Improve error handling in read builtin:
* If read -t times out, return status as if interrupted by SIGALRM
  (formerly 1).
* If a trapped signal interrupts read, return status 128+sig (formerly 1).
* If [EINTR] occurs but there is no trap, retry the read (for example
  because of a SIGWINCH in interactive mode).
* If a read error occurs, write an error message and return status 2.

As before, a variable assignment error returns 2 and discards the remaining
data read.
2013-05-03 15:28:31 +00:00
Eitan Adler
fbf59d5891 Mark usage() __dead2 2013-04-28 22:52:43 +00:00
Eitan Adler
cdbf4feea9 Remove cast that was only required for K&R C.
Reviewed by:	jilles
2013-04-28 22:05:01 +00:00
Eitan Adler
bfefd42150 Add missing static qualifiers
Reviewed by:	ed, jilles
MFC After:	3 days
2013-04-27 21:59:43 +00:00
Jilles Tjoelker
58c73bab93 sh: Don't consider jobs -s/-p as reporting the status of jobs.
This ensures that something like j=$(jobs -p) does not prevent any
status from being written to the terminal.
2013-04-27 14:07:25 +00:00
Eitan Adler
4c99904b9a Add two more 'static' qualifiers 2013-04-26 17:56:35 +00:00
Eitan Adler
9d6d3f96d0 Take some improvements from DragonFlyBSD:
- add const where appropriate
	- add static where appropriate
	- fix a whitespace issues

Reviewed by:	brooks
Obtained from:	DragonFlyBSD
MFC After:	1 week
2013-04-26 17:45:40 +00:00
Eitan Adler
d4319e7433 Add -x option to avoid crossing mount points when removing a hierarchy.
Discussed on:	-hackers
Inspired by:	DragonflyBSD
MFC After:	1 week
2013-04-26 17:45:37 +00:00
Ulrich Spörlein
e83643f4f6 Don't appease clang static analyzer after all and roll back
the free(3) of mntbuf ... again. There's no point in doing
useless extra work when we're about to exit.

See also r240565.

Not reading file history:	uqs
2013-04-26 12:27:30 +00:00
Konstantin Belousov
6784d416a5 Literally follow POSIX:
If the bs= expr operand is specified and no conversions other than sync,
noerror, or notrunc are requested, the data returned from each input
block shall be written as a separate output block.

In particular, when both bs=size and conv=sparce were specified, the
resulted file was fully filled, instead of sparce.

PR:	standards/177742
Submitted by:	Matthew Rezny <mrezny@hexaneinc.com>
MFC after:	2 weeks
2013-04-23 16:08:24 +00:00
Eitan Adler
e99f8bc02e - Add the __dead2 attribute since it is a function that never returns
- Add an empty line in usage() according to style(9)

PR:		bin/177076
Submitted by:	Fernando <fernando.apesteguia@gmail.com>
Approved by:	cperciva (mentor)
2013-04-23 13:03:11 +00:00
Joel Dahl
224359b52c Point users towards nisdomainname and rc.conf.
PR:		144630
Submitted by:	Stefan Krueger <stadtkind2@gmx.de>,
		Fel <wtfcrap@mail.ru>
2013-04-22 17:55:12 +00:00
Joel Dahl
1ca3beb91f Document a few expansions for the $PS1 and $PS2 environmental variables.
PR:		173410
Submitted by:	Derek Wood <ddwood@outlook.com>
Reviewed by:	jilles
2013-04-21 19:55:38 +00:00
Ulrich Spörlein
11ed25f278 bin/df: Fix unitialized use in prtstat
While here:
- use NULL in the context of pointers
- use memset instead of bzero throughout the file
- free memory to appease clang static analyzer

Found by:	Coverity Scan (the UNINIT one)
2013-04-20 12:41:05 +00:00
Kenneth D. Merry
21b6ee96fc Update chio(1) and ch(4) to support reporting element designators.
This allows mapping a tape drive in a changer (as reported by
'chio status') to a sa(4) driver instance by comparing the
serial numbers.

The designators can be ASCII (which is printed out directly), binary
(which is printed in hex format) or UTF-8, which is printed in either
native UTF-8 format if the terminal can support it, or in %XX notation
for non-ASCII characters.  Thanks to Hiroki Sato <hrs@> for the
explaining UTF-8 printing and example UTF-8 printing code.

chio.h:		Modify the changer_element_status structure to add new
		fields and definitions from the SMC3r16 spec.

		Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
		define a new CHIOGSTATUS ioctl.

		Clean up some tab/space issues.

chio.c: 	For the 'status' subcommand, print the designator field
		if it is supplied by a device.

scsi_ch.h:	Add new flags for DVCID and CURDATA to the READ
		ELEMENT STATUS command structure.

		Add a read_element_status_device_id structure
		for the data fields in the new standard. Add new
		unions, dt_or_obsolete and voltage_devid, to hold
		and address data from either SCSI-2 or newer devices.

scsi_ch.c:	Implement support for fetching device IDs with READ
		ELEMENT STATUS data.

		Add new arguments to scsi_read_element_status() to
		allow the user to request the DVCID and CURDATA bits.
		This isn't compiled into libcam (it's only an internal
		kernel interface), so we don't need any special
		handling for the API change.

		If the user issues the new CHIOGSTATUS ioctl, copy all of
		the available element status data out.  If he issues the
		OCHIOGSTATUS ioctl, we don't copy the new fields in the
		structure.

		Fix a bug in chopen() that would result in the peripheral
		never getting unheld if chgetparams() failed.

Sponsored by:	Spectra Logic
Submitted by:	Po-Li Soong
MFC After:	1 week
2013-04-19 20:03:51 +00:00
Ed Schouten
7e659f9491 Add the Clang specific -Wmissing-variable-declarations to WARNS=6.
This compiler flag enforces that that people either mark variables
static or use an external declarations for the variable, similar to how
-Wmissing-prototypes works for functions.

Due to the fact that Yacc/Lex generate code that cannot trivially be
changed to not warn because of this (lots of yy* variables), add a
NO_WMISSING_VARIABLE_DECLARATIONS that can be used to turn off this
specific compiler warning.

Announced on:	toolchain@
2013-04-19 19:45:00 +00:00
Jilles Tjoelker
6e0f89a4b4 sh: Don't modify exit status when break/continue/return passes !.
This matches what would happen if  ! P  were to be replaced with
if P; then false; else true; fi.

Example:
  f() { ! return 0; }; f
2013-04-12 15:19:35 +00:00
Jilles Tjoelker
7d919c164d sh: Add const to nodesavestr(). 2013-04-07 16:28:36 +00:00
Brooks Davis
c183a03b17 IFP4 change 222074.
Introduce an explicit close of the output descriptor so that work done
on close is accounted for in the summary output triggered at exit
(implicit close()s occur after atexit() hooks).

This is useful because some devices such as cfi(4) may perform
signficant work after a close occurs (e.g. erasing and rewriting a
block of flash).
2013-04-03 19:19:45 +00:00
Jilles Tjoelker
c6a453a430 sh: Write as much into the heredoc pipe as possible, to avoid forking.
Use non-blocking I/O to write as much as the pipe will accept (often 64K,
but it can be as little as 4K), avoiding the need for the ugly PIPESIZE
constant. If PIPESIZE was set too high, a deadlock would occur.
2013-04-02 21:34:38 +00:00
Jilles Tjoelker
46c6b52dfb sh: Fix various compiler warnings.
It now passes WARNS=7 with clang on i386.

GCC 4.2.1 does not understand setjmp() properly so will always trigger
-Wuninitialized. I will not add the volatile keywords to suppress this.
2013-04-01 17:18:22 +00:00
Edward Tomasz Napierala
f8992fccda Mention that read_attributes, write_attributes, read_acl and write_acl
are always permitted for the file owner.

PR:		kern/174948
MFC after:	1 week
2013-04-01 13:17:28 +00:00
Joel Dahl
5127efa399 Minor mdoc fix. 2013-03-29 08:12:09 +00:00
Jilles Tjoelker
54ccc8b588 sh(1): Mention possible ambiguities with $(( and ((.
In some other shells, things like $((a);(b)) are command substitutions.

Also, there are shells that have an extension ((ARITH)) that evaluates an
arithmetic expression and returns status 1 if the result is zero, 0
otherwise. This extension may lead to ambiguity with two subshells starting
in sequence.
2013-03-24 22:48:45 +00:00
John-Mark Gurney
699d72c5fc Fix compiling ed w/ WITHOUT_ED_CRYPTO... These variables aren't
used..

Submitted by:   deeptech71 at gmail dot com
2013-03-23 19:04:57 +00:00
Pawel Jakub Dawidek
b4b2596b97 - Make 'flags' argument to chflags(2), fchflags(2) and lchflags(2) of type
u_long. Before this change it was of type int for syscalls, but prototypes
  in sys/stat.h and documentation for chflags(2) and fchflags(2) (but not
  for lchflags(2)) stated that it was u_long. Now some related functions
  use u_long type for flags (strtofflags(3), fflagstostr(3)).
- Make path argument of type 'const char *' for consistency.

Discussed on:	arch
Sponsored by:	The FreeBSD Foundation
2013-03-21 22:44:33 +00:00
Jilles Tjoelker
d70ad6f2d0 sh: Recognize "--" and explicitly reject options in wait builtin.
If syntactically invalid job identifiers are to be taken as jobs that exited
with status 127, this should not apply to options, so that we can add
options later if need be.
2013-03-15 20:29:31 +00:00
Joel Dahl
e9e3a1ab1f Add a few examples.
Obtained from:	OpenBSD
2013-03-15 20:12:54 +00:00
Jilles Tjoelker
3fe1119f98 sh: When executing a trap, keep exit status along with evalskip.
This ensures 'return' in a trap returns the correct status to the caller.

If evalskip is not set or if it is overridden by a previous evalskip, keep
the old behaviour of restoring the exit status from before the trap.
2013-03-03 17:33:59 +00:00
Peter Jeremy
293beebc46 Enhance test(1) by adding provision to compare any combination of the
access, birth, change and modify times of two files, instead of only
being able to compare modify times.  The builtin test in sh(1) will
automagically acquire the same expansion.

Approved by:	grog
MFC after:	2 weeks
2013-02-25 19:05:40 +00:00
Jilles Tjoelker
25e0f0f577 sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig. 2013-02-23 22:50:57 +00:00
Jilles Tjoelker
e9e9223546 sh: Fix a crash with the stackmark code.
If a stack mark is set while the current stack block is empty, the stack
block may move later on (because of realloc()) and the stack mark needs to
be updated. This updating does not happen after popstackmark() has been
called; therefore, call setstackmark() again if the stack mark is still
being used.

For some reason, this only affects a few users. I cannot reproduce it. The
situation seems quite rare as well because an empty stack block would
usually be freed (by popstackmark()) before execution reaches a
setstackmark() call.

PR:		175922
Tested by:	KT Sin
2013-02-19 23:46:51 +00:00
Edward Tomasz Napierala
a3bc22a09b Fix NFSv4 permission description in setfacl(1) manual page: the 'D'
means delete_child, not delete.

MFC after:	1 week
2013-02-08 18:43:47 +00:00
Edward Tomasz Napierala
bac44ad218 Improve description of the "-m" option to setfacl(1).
Submitted by:	scottl
MFC after:	1 week
2013-02-08 18:12:16 +00:00
Edward Tomasz Napierala
5293f9bee4 In the setfacl(1) manual page, make it clear that for NFSv4 ACLs,
one should really use -a and -x instead of -m.

MFC after:	1 week
2013-02-08 18:02:28 +00:00
Jilles Tjoelker
1767d529f2 sh: Simplify mksyntax and make it fit for cross-compiling.
Now it outputs fixed files, which use constants provided by the C standard
library to determine appropriate values for the target machine.

Before, mksyntax inspected the host machine which resulted in subtle
breakage if e.g. char is signed on the host and unsigned on the target such
as when cross-compiling on x86 for ARM.

Tested using -funsigned-char on amd64. Compiling build-tools without it and
sh itself with it causes various tests to fail without this change but not
with this change. With consistent -funsigned-char, tests pass with or
without this change.

The mksyntax program could be removed and syntax.c and syntax.h committed to
the repository.

Submitted by:	Christoph Mallon
MFC after:	2 weeks
2013-02-07 22:42:33 +00:00
Jilles Tjoelker
eb64a9137b sh: Fix a comment. 2013-02-07 21:24:10 +00:00
Xin LI
5be97e72e6 Catch TRACE parameters up with r238888. This change is only needed when
debugging is enabled.
2013-02-07 19:00:54 +00:00
Konstantin Belousov
45732078c1 Document P_PPTRACE.
MFC after:	2 weeks
2013-02-07 15:37:51 +00:00
Jilles Tjoelker
eaf7719957 sh: Do not test for digit_contig in mksyntax.
ISO/IEC 9899:1999 (E) 5.2.1p3 guarantees that the values of the characters
0123456789 are contiguous.

The generated syntax.c and syntax.h remain the same.

Submitted by:	Christoph Mallon
2013-02-05 22:54:09 +00:00
Jilles Tjoelker
4dc6bdd3e7 sh: Expand here documents in the current process.
Expand here documents at the same point other redirections are expanded but
use a non-fork subshell environment (like simple command substitutions) for
compatibility. Substitition errors result in an empty here document like
before.

As a result, a fork is avoided for short (<4K) expanded here documents.

Unexpanded here documents (with quoted end marker after <<) are not affected
by this change. They already only forked when >4K.

Side effects:
* Order of expansion is slightly different.
* Slow expansions are not executed in parallel with the redirected command.
* A non-fork subshell environment is subtly different from a forked process.
2013-02-03 15:54:57 +00:00
Jilles Tjoelker
58570ac4a5 sh: Prefer our character classification functions to <ctype.h>. 2013-01-31 22:10:57 +00:00
Jilles Tjoelker
f9b7cc523d sh: Show negated commands (!) in jobs output. 2013-01-31 21:50:44 +00:00
Joel Dahl
e38120d46f Fix date. 2013-01-29 20:01:47 +00:00
Brooks Davis
aece80a2e8 Add -l option to cat(1). This option causes cat(1) to use fcntl(2) to
set an exclusive advisory lock on stdout.  This will be used to guarantee
orderly writing to METALOG.

Sponsored by:	DARPA, AFRL
Obtained from:	NetBSD (mason)
2013-01-29 18:19:40 +00:00
Mark Johnston
111a5d7c78 Return with an error from copy_link(), copy_fifo() and copy_special() if
the -n option is specified and the destination file exists.

PR:		bin/174489
Approved by:	rstone (co-mentor)
MFC after:	2 weeks
2013-01-27 05:59:28 +00:00
Xin LI
d6a55c6d3f Don't time travel back and use a present date.
Noticed by:	mckusick
2013-01-25 18:47:16 +00:00
Xin LI
7eb55d4d13 - Wrap long line;
- Add -, to SYNOPSIS section.

MFC after:	2 weeks
2013-01-24 05:36:37 +00:00
David E. O'Brien
e4573a9a7b Return "failure" as we do for 'cp -i' and a "n" answer.
Otherwise with '-v' we print out the file name as if it was copied:
   /tmp/2gb-card/M0132.CTG not overwritten
   /mnt/DCIM/CANONMSC/M0132.CTG -> /tmp/2gb-card/M0132.CTG
2013-01-23 02:06:20 +00:00
Joel Dahl
cb5a6a58cb Add FILES section.
Discussed with:	jilles
2013-01-22 18:02:58 +00:00
Joel Dahl
5dd78c9f36 Change the $ENV example to use .shrc instead of .shinit. This is consistent
with what we use in /usr/share/skel/dot.profile.

Discussed with: jilles
2013-01-20 22:25:25 +00:00
Jilles Tjoelker
84edde8b1a sh: Move some stackmarks to fix high memory usage in some loops.
If a loop contained certain commands (such as redirected compound commands),
the temporary memory for the redirection was not freed between iterations of
the loop but only after the loop.

Put a stackmark in evaltree(), freeing memory whenever a node has been
evaluated. Some other stackmarks are then redundant; remove them.

Example:
  while :; do { :; } </dev/null; done
2013-01-20 21:28:05 +00:00
Jilles Tjoelker
59e0cc8e4a sh: Remove mkinit's initialization routine.
Instead, call the only init function left directly from main().
2013-01-20 12:44:50 +00:00
Jilles Tjoelker
60a6bf2a5a sh: Replace an mkinit use with an initialization. 2013-01-19 22:12:08 +00:00
John Baldwin
9f0b6e5e27 - Move 'showthreads' check out of fmt.c.
- Update shadow copy of fmt_argv() prototype in w.c and fix calls for
  additional parameter.
2013-01-19 00:21:55 +00:00
John Baldwin
1c67ef129f Include the thread name along with the command name when displaying the
command name of a thread from a multi-threaded process that doesn't have
an available argument list (such as kernel processes) and threads display
is enabled via -H.

Reviewed by:	alfred, delphij, eric@vangyzen.net
MFC after:	1 week
2013-01-18 18:24:40 +00:00
Eitan Adler
76d916f1f5 Remove useless variable 'Pflag':
-P is an alternative to -H and -L, and it is implemented using the Hflag and Lflag variables.

Approved by:	cperciva
MFC after:	3 days
2013-01-17 04:20:31 +00:00
Xin LI
f3de285bbf Use a different way to silence clang analyzer as done in r245494 by
explicitly telling the compiler that we are on the exit route.

X-MFC:	together with r245494
2013-01-16 18:15:25 +00:00
Eitan Adler
28e4657584 Free memory before exiting in order to silence a warning from the clang
static analyzer

Approved by:	cperciva
MFC after: 	3 days
2013-01-16 05:03:52 +00:00
Jilles Tjoelker
523646ee5c sh: Simplify cd-hash interaction.
Instead of rechecking relative paths for all hashed utilities after a cd,
track if any utility in cmdtable depends on a relative path in PATH.
If there is such a utility, cd clears the entire table.

As a result, the '*' in hash no longer happens.
2013-01-14 16:40:50 +00:00
Jilles Tjoelker
925420d09c sh: Pass $? to command substitution containing compound/multiple commands.
Example:
  false; echo $(echo $?; :)
2013-01-14 12:20:55 +00:00
Jilles Tjoelker
31d396587e sh: Fix crash when parsing '{ } &'.
MFC after:	1 week
2013-01-13 19:26:33 +00:00
Jilles Tjoelker
2c090c7168 sh: Don't lose $? when backquoted command ends with semicolon or newline.
An empty simple command was added and overwrote the exit status with 0.

This affects `...` but not $(...).

Example:
  v=`false;`; echo $?
2013-01-13 19:19:40 +00:00
Andrew Turner
3c96f482d9 When WCHAR_MIN == 0 the check if a wchar_t value will always be true. In
this case skip the test as gcc complains it is always true.
2013-01-06 02:50:38 +00:00
Glen Barber
955e0a6bd2 Fix wording nit.
PR:		174787
Submitted by:	Cody Rank
MFC after:	3 days
2012-12-28 22:06:33 +00:00
Jilles Tjoelker
a68c6b5790 test(1): Document == alias for =.
Reviewed by:	gjb
Requested by:	gjb
MFC after:	1 week
2012-12-27 13:21:37 +00:00
Jilles Tjoelker
cdbd40cbb2 sh: Prefer strsignal() to accessing sys_siglist directly.
Accessing sys_siglist directly requires rtld to copy it from libc to the sh
executable's BSS. Also, strsignal() will put in the signal number for
unknown signals (FreeBSD-specific) so we need not do that ourselves.

Unfortunately, there is no function for sys_signame.
2012-12-25 14:17:09 +00:00
Kevin Lo
a5752d55e0 Fix socket calls on error post-r243965.
Submitted by:	Garrett Cooper
2012-12-21 15:54:13 +00:00
Jilles Tjoelker
d6d66cfc00 sh: Detect and flag write errors on stdout in builtins.
If there is a write error on stdout, a message will be printed (to stderr)
and the exit status will be changed to 2 if it would have been 0 or 1.

PR:		bin/158206
2012-12-12 22:01:10 +00:00
Pawel Jakub Dawidek
64b0bf0bb6 Use kern.max_pid sysctl to obtain maximum PID number instead of using local
define.

Reviewed by:	jhb
2012-12-12 15:45:03 +00:00
Greg Lehey
6b7aceb85b Handle large negative block counts correctly.
MFC after:	 2 weeks
2012-12-12 04:18:25 +00:00
Greg Lehey
71cfc6780e Update man pages and clarify a number of options.
Rework block count calculations to work correctly with small "block" sizes.

MFC after:	14 days
2012-11-16 03:33:34 +00:00
Sergey Kandaurov
d7e8bab568 Fix section number for pstat and swapinfo cross references.
MFC after:	3 days
2012-11-15 21:22:50 +00:00
Eitan Adler
b7d1b37159 Follow the behavior as specified in POSIX:
if (exists AND (NOT f_option) AND
	((not_writable AND input_is_terminal) OR i_option))
		prompt

in particular, add the test for input_is_terminal

PR:		bin/173039
Submitted by:	Mark Johnston <markjdb@gmail.com>
Approved by:	cperciva
MFC after:	3 days
2012-11-15 15:05:51 +00:00
Greg Lehey
019e4a53cb Add , (comma) option to print sizes grouped and separated by thousands
using the non-monetary separator returned by localeconv(3), typically
a comma or period.

MFC after:  14 days
2012-11-15 03:39:21 +00:00
Jilles Tjoelker
22bec20ba9 sh: Remove an unused variable. 2012-11-14 14:08:24 +00:00
Jilles Tjoelker
35dab8598a sh: Forward-declare struct alias instead of giving up type safety via void * 2012-11-11 15:13:24 +00:00
Peter Wemm
d272a5b786 Undo over-aggressive conversion of spaces to tabs. ie: those within
format strings, "period, space, space" in comment text, etc.
2012-11-09 20:19:56 +00:00
Greg Lehey
dfd91f79a3 Replace spaces with tabs where appropriate.
Reminded by: jh@
2012-11-08 23:45:19 +00:00
Jilles Tjoelker
e964872f18 sh: Fix two issues when an alias is redefined:
* The last character is not displayed.
 * If the alias ends with itself (as a word), an infinite memory-eating loop
   occurs.

If an alias is defined initially, a space is appended to avoid recursion but
this did not happen when an alias was later modified.

PR:		bin/173418
Submitted by:	Daniel F.
MFC after:	1 week
2012-11-08 13:33:48 +00:00
Greg Lehey
9aa68a3ffa Add y flag and environment variable LS_SAMESORT to specify the same
sorting order for time and name with the -t option.  IEEE Std 1003.2
(POSIX.2) mandates that the -t option sort in descending order, and
that if two files have the same timestamp, they should be sorted in
ascending order of their names.  The -r flag reverses both of these
sort orders, so they're never the same.  This creates significant
problems for sequentially named files stored on FAT file systems,
where it can be impossible to list them in the order in which they
were created.

Add , (comma) option to print file sizes grouped and separated by
thousands using the non-monetary separator returned by localeconv(3),
typically a comma or period.

MFC after:  14 days
2012-11-08 00:24:26 +00:00
Greg Lehey
44f17a8111 Sort option parsing as far as practical. 2012-11-07 23:37:24 +00:00
Jilles Tjoelker
d172408c7e sh: Change cmdtype in tblentry from short to signed char.
If this is a smaller type than int anyway, we can make it the smallest
possible.
2012-11-05 17:52:18 +00:00
Jilles Tjoelker
422c281c83 sh: Use C99 flexible array instead of accessing array beyond bounds.
Although sufficient memory is available for a longer string in cmdname,
this is undefined behaviour anyway.

Side effect: for alignment reasons, an additional byte of memory is
allocated per hashed command.
2012-11-03 22:23:08 +00:00
Joel Dahl
8850c7d71f Add a couple of examples.
Obtained from:	OpenBSD
2012-11-02 22:32:47 +00:00
Ed Schouten
eccad22277 More -Wmissing-variable-declarations fixes.
In addition to adding missing `static' keywords:
- bin/dd: Pull in `extern.h' to guarantee consistency with source file.
- libexec/rpc.rusersd: Move shared globals into an extern.h.
- libexec/talkd: Move `debug' and `hostname' into extern.h.
- usr.bin/cksum: Put counters in extern.h, as they are used by ckdist/mtree.
- usr.bin/m4: Move `end_result' into extern.h.
- usr.sbin/services_mkdb: Move shared globals into an extern.h.
2012-10-20 10:33:15 +00:00
Ed Schouten
bf70becee6 More -Wmissing-variable-declarations fixes.
In addition to adding `static' where possible:

- bin/date: Move `retval' into extern.h to make it visible to date.c.
- bin/ed: Move globally used variables into ed.h.
- sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings.
- usr.bin/calendar: Remove unneeded variables.
- usr.bin/chat: Make `line' local instead of global.
- usr.bin/elfdump: Comment out unneeded function.
- usr.bin/rlogin: Use _Noreturn instead of __dead2.
- usr.bin/tset: Pull `Ospeed' into extern.h.
- usr.sbin/mfiutil: Put global variables in mfiutil.h.
- usr.sbin/pkg: Remove unused `os_corres'.
- usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'.
2012-10-19 14:49:42 +00:00
Ed Schouten
ae824d80f2 Fix warnings found by -Wmising-variable-declarations.
This self-written compiler warning, which is hopefully going to be
committed into LLVM sources soon, warns about potentially missing
`static' keywords, similar to -Wmissing-prototypes.

- bin/pax: Move external declaration of chdname and s_mask into extern.h.
- bin/setfacl: Move setfacl.c-specific stuff out of setfacl.h.
- sbin/mount_fusefs: Remove char *progname; use getprogname().
- others: add `static' where possible.
2012-10-19 05:43:38 +00:00
Joel Dahl
a2442c2fa9 mdoc: don't nest displays. The markup here isn't adding anything anyway.
Fixes a mandoc lint warning.

Discussed with:	brueffer, Jason McIntyre <jmc@kerhand.co.uk>
2012-10-14 13:59:17 +00:00
Matthew D Fleming
6db1a7f11e Fix bin/ build with a 64-bit ino_t.
Original code by:	Gleb Kurtsou
2012-09-27 23:31:12 +00:00
Andrey Zonov
08c62f8deb - Bump date.
Submitted by:	pluknet
Approved by:	kib (mentor)
X-MFC-With:	r240645
2012-09-18 13:24:14 +00:00
Andrey Zonov
38f2be1c54 - Add 'dsiz' and 'ssiz' keywords to show data and stack size respectively.
Approved by:	kib (mentor)
MFC after:	1 week
2012-09-18 12:25:14 +00:00
Eitan Adler
65e415b16e Revert 240527:
mntbuf can poit to memory allocated by getmntinfo(3) which can't be freed

PR:		bin/171634
Approved by:	cperciva (implicit)
2012-09-16 16:08:20 +00:00
Jilles Tjoelker
7cbda73825 sh: Prefer internal nextopt() to libc getopt().
This reduces code duplication and code size.

/usr/bin/printf is not affected.

Side effect: different error messages when certain builtins are passed
invalid options.
2012-09-15 21:56:30 +00:00