Commit Graph

2329 Commits

Author SHA1 Message Date
ru
3371e72606 Express in the usage() and SYNOPSIS that -F depends on -s, and
that -f and -i are exclusive.
2007-11-17 21:01:22 +00:00
ru
4a831eed37 Swap "source"/"target" where appropriate, to match documentation. 2007-11-17 20:24:58 +00:00
jhb
4885bf6afb Teach ps(1) to parse pts TT values (i.e. '0', '1') for the -t flag.
MFC after:	1 week
Reported by:	kris
2007-11-08 22:31:28 +00:00
ru
d6fe5a293a Bump document date on behalf of previous revision. 2007-11-01 09:49:45 +00:00
julian
6b31aa449c fix sorting of 'tdnam' keyword in keyword list. 2007-10-28 17:10:36 +00:00
julian
11e1aa0d18 Introduce a way to make pure kernal threads.
kthread_add() takes the same parameters as the old kthread_create()
plus a pointer to a process structure, and adds a kernel thread
to that process.

kproc_kthread_add() takes the parameters for kthread_add,
plus a process name and a pointer to a pointer to a process instead of just
a pointer, and if the proc * is NULL, it creates the process to the
specifications required, before adding the thread to it.

All other old kthread_xxx() calls return, but act on (struct thread *)
instead of (struct proc *). One reason to change the name is so that
any old kernel modules that are lying around and expect kthread_create()
to make a process will not just accidentally link.

fix top to show  kernel threads by their thread name in -SH mode
add a tdnam formatting option to ps to show thread names.

make all idle threads actual kthreads and put them into their own idled process.
make all interrupt threads kthreads and put them in an interd process
(mainly for aesthetic and accounting reasons)
rename proc 0 to be 'kernel' and it's swapper thread is now 'swapper'

man page fixes to follow.
2007-10-26 08:00:41 +00:00
stefanf
7dc3b250aa The exit status of a case statement where none of the patterns is matched
is supposed to be 0, not the status of the previous command.

Reported by:	Eygene Ryabinkin
PR:		116559
Approved by:	re (gnn)
2007-10-04 16:14:48 +00:00
kevlo
a3a58105f1 Use owner name and owning group name instead of uid and gid
for displaying the three-line comment header by default.

Reviewed by: kientzle
Approved by: re (bmah)
2007-09-19 02:04:47 +00:00
jeff
3fc0f8b973 - Move all of the PS_ flags into either p_flag or td_flags.
- p_sflag was mostly protected by PROC_LOCK rather than the PROC_SLOCK or
   previously the sched_lock.  These bugs have existed for some time.
 - Allow swapout to try each thread in a process individually and then
   swapin the whole process if any of these fail.  This allows us to move
   most scheduler related swap flags into td_flags.
 - Keep ki_sflag for backwards compat but change all in source tools to
   use the new and more correct location of P_INMEM.

Reported by:	pho
Reviewed by:	attilio, kib
Approved by:	re (kensmith)
2007-09-17 05:31:39 +00:00
scf
667a20c9f2 Take care that the input to setenv() may actually be a pointer straight
from environ; make a copy before manipulating it and passing it to
setenv().

Approved by:	wes
Approved by:	re (kensmith)
2007-07-06 04:04:58 +00:00
scf
196b6346ba Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

Convert all calls to POSIX from historic BSD API:
 - unsetenv returns an int.
 - putenv takes a char * instead of const char *.
 - putenv no longer makes a copy of the input string.
 - errno is set appropriately for POSIX.  Exceptions involve bad environ
   variable and internal initialization code.  These both set errno to
   EFAULT.

Several patches to base utilities to handle the POSIX changes from
Andrey Chernov's previous commit.  A few I re-wrote to use setenv()
instead of putenv().

New regression module for tools/regression/environ to test these
functions.  It also can be used to test the performance.

Bump __FreeBSD_version to 700050 due to API change.

PR:		kern/99826
Approved by:	wes
Approved by:	re (kensmith)
2007-07-04 00:00:41 +00:00
kensmith
ebb27bf310 Don't include encryption features of ed(1) when building for the
"rescue media" bundled with releases.

Suggested by:	ru
Approved by:	re (hrs)
2007-07-02 14:00:25 +00:00
remko
b9a03d8bb1 Correct the referenced securelevel document, it's now securelevel 7.
Pointed out by:	ru
2007-06-02 20:15:59 +00:00
pjd
1e65a8c945 Fix probably copy&paste from chmod(1) - we change file flags here, not mode. 2007-05-28 04:23:09 +00:00
brian
ca73550609 Remove unnecessary free argument casts.
Don't abuse arcname's constness.
2007-05-25 17:53:38 +00:00
rse
22615a5b86 Cleanup pax(1) sources a little bit while I poked around in them:
- remove a superfluous doubled trailing semicolon.
- remove the extra void casts on calls to void-function free(3).
2007-05-24 06:44:37 +00:00
cperciva
e4c186657b In the error handling path, don't call close(fd) if the error we're
handling is that fd = open(foo) is -1.  This bug is harmless since
close(-1) just returns an error (which the code ignores).

Found by:	Coverity Prevent(tm)
CID:		1503 (in userland test run)
2007-05-22 04:21:00 +00:00
mp
9df330a802 Work around a vendor issue that was causing the builtin malloc to be
used instead of the system malloc.

Submitted by:	ume
2007-05-16 21:22:38 +00:00
pav
687d073a67 Replace a fairly opaque sentence with a much clearer wording from NetBSD.
PR:		docs/101330 (inspired by)
Submitted by:	Peter Gildea <peter@gildea.com>
Obtained from:	NetBSD
2007-05-12 22:18:27 +00:00
ache
6ccaf050cc Back out all POSIXified *env() changes.
Not because I admit they are technically wrong and not because of bug
reports (I receive nothing). But because I surprisingly meets so
strong opposition and resistance so lost any desire to continue that.

Anyone who interested in POSIX can dig out what changes and how
through cvs diffs.
2007-05-01 16:02:44 +00:00
ache
4d05f6527a Simplify previous fix and disallow VTEXTFIXED direct pass for putenv() too,
just use savestr()
2007-04-30 15:01:33 +00:00
ache
ac682a1ec2 Put some safeguards:
1) Under POSIX unsetenv("foo=bar") is explicit error and not equal
to unsetenv("foo")
2) Prepare for upcomig POSIXed putenv() rewrite: make putenv() calls
portable and conforming to standard.
2007-04-30 11:44:42 +00:00
ache
2e498f754e Eliminate error with -W* strict flags and make putenv() calls conforming to
standard in the same way as f.e. gcc internal portable code does.
2007-04-30 04:29:17 +00:00
pjd
a7cca495b2 Move uuidgen(1) from /usr/bin/ to /bin/. It will be used in rc.d/hostid
script, which will be executed before /usr/ mount.

Reviewed by:	mlaier, rink, brooks, rwatson
2007-04-09 19:16:48 +00:00
kan
eac6857b97 getblocksize expects pointer to long as a second argument, not
a pointer to u_long.
2007-04-06 15:36:43 +00:00
mp
36b44d59ff Build updates for tcsh-6.15.00 import.
Reviewed by:	ume
Reminded by:	Divacky Roman
MFC after:	1 week
2007-03-11 22:41:19 +00:00
will
3483dab550 Fix a bug where the mutual exclusivity of the -l and -t options is not
recognized properly if -l is specified first.

PR:			bin/105721
MFC after:	1 week
2007-03-08 06:10:17 +00:00
ru
cabb128e11 Fix markup. 2007-03-04 19:52:07 +00:00
ru
66581633ca Fix markup. 2007-03-04 09:15:12 +00:00
ru
dd2bbfcd28 Fix markup. 2007-02-28 10:29:48 +00:00
ru
22ef9e3f5c Fix markup. 2007-02-27 11:25:58 +00:00
mckusick
271ce58544 Implement the -h flag (set an ACL on a symbolic link).
Before this fix the -h flag was ignored (i.e. setfacl
always set the ACL on the file pointed to by the symbolic
link even when the -h flag requested that the ACL be set
on the symbolic link itself).
2007-02-26 00:42:17 +00:00
ceri
0eef1e3be2 Correct typos containing my login name (plus one more in expr.y).
Found courtesy of a recursive grep in the wrong directory.
2007-02-18 19:48:59 +00:00
stefanf
542ee93dab Use eaccess() instead of access() for the type builtin, like we do for the
test builtin.

Submitted by:	Martin Kammerhofer
2007-01-18 22:31:22 +00:00
stefanf
69e741477c Return an error status (127) from the builtins 'type' and 'command' (with
either -v or -V) if a file with a slash in the name doesn't exist (if there is
no slash we already did that).

Additionally, suppress the error message for command -v for files with a slash.

PR:		107674
Submitted by:	Martin Kammerhofer
2007-01-11 00:19:00 +00:00
ru
0f6657a760 Fix markup. 2006-12-27 12:14:56 +00:00
ru
bea4c2efb0 More markup fixes. 2006-12-27 11:28:00 +00:00
ru
0f2436332c Fix markup. 2006-12-27 11:19:06 +00:00
ru
59b8e8a6d2 Give a hint to the reader as to what the "whiteout" actually means. 2006-12-26 13:57:40 +00:00
ru
9b2078d255 Fix markup, add the EXIT STATUS section. 2006-12-26 13:44:41 +00:00
ru
06bb6eb3fd One more nit. 2006-12-23 09:25:23 +00:00
ru
cce30d6dfc Fix markup. 2006-12-23 09:22:06 +00:00
ru
9c271abc0d - Mention umask(2) when first referring to it.
- Add missing markup.

Submitted by:	Eugene Grosbein <eugen@grosbein.pp.ru>
2006-12-22 07:28:38 +00:00
ru
43f209bdda Use a standard section name. 2006-12-18 15:45:01 +00:00
ru
d828ea0690 Simplify some markup. 2006-12-14 10:42:46 +00:00
kientzle
257e9215d1 Style(9) fixes, thanks to Ruslan. 2006-12-08 07:47:08 +00:00
kientzle
dd35a61767 Support the "-f" option by simply ignoring it.
This allows script compatibility with Linux, whose
"hostname" is the same as BSD "hostname -s".
With this change, "hostname -f" is the same on
both systems.

MFC after: 7 days
2006-12-08 07:19:51 +00:00
ru
2b43628e6b Once upon a time, the hostname was being set in the /etc/netstart,
which can be called a "network initialization script", now that it
is set in /etc/rc.d/hostname, "network" sounds confusing, so remove
it.
2006-12-05 12:09:50 +00:00
ru
04681b9d6f Fix some of the alignment warnings on ARM. 2006-11-27 22:17:11 +00:00
stefanf
085fc40080 Fix expanding of quoted positional parameters in case patterns.
Obtained from:	NetBSD (expand.c 1.58 and 1.59)
Submitted by:	Paul Jarc
PR:		56147
2006-11-07 22:46:13 +00:00
stefanf
d02f26394e When parsing an invalid parameter expansion (eg. ${} or ${foo@bar}) do not
issue a syntax error immediately but save the information that it is erroneous
for later when the parameter expansion is actually done.  This means eg. "false
&& ${}" will not generate an error which seems to be required by POSIX.
Include the invalid parameter expansion in the error message (sometimes
abbreviated with ... because recovering it would require a lot of code).

PR:		105078
Submitted by:	emaste
2006-11-05 18:36:05 +00:00
ceri
e83c4c55c0 Fix typo. 2006-11-02 19:10:05 +00:00
delphij
7af07c0c57 Correct a security issue introduced in previous commit:
instead of removing the file and issue a warning about
the removal, do not do any operation at all in case -P
is specified when the dinode has hard links.

With -f and -P specified together, we assume that the
user wants rm to overwrite the contents of the file
and remove it (destroy the contents of file but leave
its hard links as is).

The reason of doing it this way is that, in case where
a hard link is created by a malicious user (currently
this is permitted even if the user has no access to the
file).  Losing the link can potentially mean that the
actual owner would lose control completely to the user
who wants to obtain access in a future day.

Discussed with:	Peter Jermey
2006-10-31 02:22:36 +00:00
delphij
633d73890b Be more reasonable when overwrite mode is specified while there
is hard links.  Overwritting when links > 1 would cause data
loss, which is usually undesired.

Inspired by:	discussion on -hackers@
Suggested by:	elessar at bsdforen de
Obtained from:	OpenBSD
2006-10-30 03:32:09 +00:00
trhodes
3e2d73c3e9 Wording nits. 2006-10-27 08:26:24 +00:00
trhodes
e0efadd7e5 Flesh out the compatibility section a little bit. Bump doc date. 2006-10-24 18:42:42 +00:00
maxim
065ac6f82d o Backout rev. 1.55. Don't waste cpu cycles for bzero(), do not
call chflags() for whiteouted files.

Prodded by:	ru
2006-10-18 13:16:06 +00:00
ru
5968c5802f Avoid a spurious warning for each whiteout found during "ls -lW".
# ls -lW
total 2
-rw-r--r--  1 root  wheel  6 Oct 18 14:46 file1
ls: ./file2: No such file or directory
w---------  0 root  wheel  0 Jan  1  1970 file2
2006-10-18 10:58:27 +00:00
maxim
ebbb5a2544 o Zero out struct stat before usage. lstat(2) can fail and
leave garbage there which will break -W code path.

PR:		bin/84569
Submitted by:	Igor
MFC after:	2 weeks
2006-10-18 08:22:33 +00:00
ru
ad0b8e41c7 - Improve description of the -A option.
- Document how whiteouts look in the long output. [1]
- Sort entry types.
- Fix description of the socket type.

PR:		docs/51921 [1]
2006-10-12 10:08:52 +00:00
trhodes
ca75959a96 Fix style(9) bugs in previous commit.
Lesson from:	bde
2006-10-11 10:26:34 +00:00
ru
7b5daf2d9b Adhere to POSIX: the -m option only applies to the newly created
directories; it should not change the permission bits of already
existing directories.

Submitted by:	Alex Unleashed (modified by me)
2006-10-10 20:18:20 +00:00
trhodes
06666564b4 Make -r a synonym for -R, similar to behavior on Linux while being backwards
compatible with old -r behavior with regards to -L.  You can now copy fifos
and other special files with -r.

Reviewed by:	-standards (long ago), das, bde
Approved by:	bde (recently)
2006-10-07 22:14:43 +00:00
stefanf
7819e9ab69 Add the POSIX option -p to the jobs builtin command. It prints the PID of the
process leader for each job.  Now the last specified option for the output
format (-l, -p or -s) wins, previously -s trumped -l.

PR:		99926
Submitted by:	Ed Schouten and novel (patches modified by me)
2006-10-07 16:51:16 +00:00
maxim
1f6d578128 o Style(9).
Submitted by:	bde
2006-10-07 12:14:50 +00:00
maxim
a9cb1cf4c1 o Avoid division by zero.
o Place error checking code near to the syscall.

Submitted by:	bde
2006-10-07 12:11:21 +00:00
maxim
157dbabffd o Hold copied bytes counter in off_t. This prevents statistics
displayed by SIGINFO handler from overflow.

PR:		bin/104039
Submitted by:	Geoffrey Giesemann
MFC after:	2 weeks
2006-10-06 08:30:33 +00:00
ru
92c5371767 Move the -l option processing to where it belongs.
Overall still not kosher but better matches style(9).
2006-09-29 06:06:39 +00:00
csjp
2fbe025d48 Based on The Open Group Base Specifications Issue 6 IEEE Std 1003.1, our
current implementation of df(1) is does not properly format the output under
certain conditions. Right now -kP and -Pk are not the same thing. Further,
when we set the BLOCKSIZE environment variable, we use "1k" instead of "1024",
making the header display incorrectly.

To quote the specification:

"When both the -k and -P options are specified, the following header line
 shall be written (in the POSIX locale):

"Filesystem 1024-blocks Used Available Capacity Mounted on\n"

- If -P has been specified, check to make sure that -k has not already been
  specified, if so, simply break instead of clobbering the previous blocksize
- Use 1024 instead of 1k to make the header POSIX compliant

Reported by:	Andriy Gapon
Discussed with:	bde, ru
MFC after:	1 week
2006-09-20 20:55:02 +00:00
ru
36d05684e7 Markup fixes. 2006-09-17 17:40:07 +00:00
ru
a48b0e1228 - Fix options order.
- Touch manpage's document date.
2006-08-25 09:58:13 +00:00
ru
1f50dbf4f2 Remove a stray -a option that probably sneaked in from julian's
attempt to enter append mode twice in vi(1).  :-)
2006-08-25 09:42:16 +00:00
julian
b0fd0e6925 Add an option to allow copying of a hierarchy while linking he regular files.
Bikeshedded to death on: hackers
Submitted by:andersonatcenttech.com
MFC in: 1 month
2006-08-24 20:45:38 +00:00
yar
a5e7380f7b For the sake of clarity, explicitly tell that comma and space
characters can be included in a custom column title string --
that's why it may appear at the end of a keyword list argument
only.
2006-08-21 03:09:12 +00:00
imp
9616e66c60 Prefer strlcpy to strncpy. In one case, this saves us from re-zeroing
data that's alreday 0.  In another, it saves us from zeroing data that
will be overwritten again.
2006-08-20 06:32:40 +00:00
imp
f6de1709c1 Use strlcpy in place of strncpy + setting the last character NUL. To
be safe, memset the entire msg to '0'.
2006-08-20 06:31:24 +00:00
yar
ad697718d2 Document a detail in the present syntax of "ps -o foo=bar". Now
the header title string "bar" extends to the end of the argument
even if it contains commas or spaces, unlike in RELENG_4 or earlier.
The modern syntax agrees with SUSv3.

MFC after:	3 days
2006-08-18 14:12:38 +00:00
imp
5c08c82362 while(0); -> while (0) in multiline macro 2006-08-17 23:00:33 +00:00
yar
209e4786e7 Commit the results of the typo hunt by Darren Pilgrim.
This change affects documentation and comments only,
no real code involved.

PR:		misc/101245
Submitted by:	Darren Pilgrim <darren pilgrim bitfreak org>
Tested by:	md5(1)
MFC after:	1 week
2006-08-04 07:56:35 +00:00
yar
e8d2a6dffb Do not forget to increment the input line counter
when reading a word spanning multiple lines.

PR:		bin/101094
MFC after:	5 days
2006-07-31 11:32:12 +00:00
yar
19e36da670 Granting the amount of misunderstanding the last change received,
extend it with an example to clarify the point.
2006-07-31 09:25:20 +00:00
yar
7c73bda70d Tell more of the sh(1) history.
Acknowledge Kenneth Almquist's contribution in AUTHORS.

MFC after:	5 days
2006-07-29 09:56:29 +00:00
yar
70bf44eb7c Document that both sides of -a or -o are always evaluated. This
"feature" doesn't seem to be in the standards or elsewhere, and
it is against what we are used to in C and sh(1), so put the
paragraph under BUGS.

Pointed out by:	dougb
MFC after:	3 days
2006-07-27 19:08:21 +00:00
yar
62b37c693c Make it easier to find that we have test(1) built-in in sh(1).
MFC after:	3 days
2006-07-26 06:48:18 +00:00
markm
f6ff2e99e6 More inactive maintainers. 2006-07-09 21:47:37 +00:00
maxim
9926c77bc7 o Call fts_close() before exit.
Obtained from:	NetBSD, Coverity ID 1754
2006-07-04 20:52:36 +00:00
yar
642780c004 Document the fact that 'true' and 'false' are among sh(1) built-in commands.
MFC after:	3 days
2006-06-21 12:01:52 +00:00
stefanf
9755dcd8db Merge NetBSD's revision 1.86: Don't crash on "<cmd> | { }". 2006-06-15 07:57:05 +00:00
stefanf
40616c7bb3 Implement the PS4 variable which is defined by the POSIX User Portability
Utilities option.  Its value is printed at the beginning of the line if tracing
(-x) is active.  PS4 defaults to the string "+ " which is compatible with the
old behaviour to always print "+ ".

We still need to expand variables in PS1, PS2 and PS4.

PR:		46441 (part of)
Submitted by:	schweikh
Obtained from:	NetBSD
2006-06-15 07:00:49 +00:00
stefanf
ec7a449207 Don't strip a leading ./ from the path for the cd builtin to avoid interpreting
.//dir as /dir.  Rather strip it only for the purpose of checking if the
directory path should be printed.

PR:		88813
Submitted by:	Josh Elsasser
Patch from:	NetBSD (cd.c rev 1.38)
MFC after:	2 weeks
2006-06-12 21:06:00 +00:00
maxim
50f099ffb3 o Fix grammar, format. 2006-06-09 17:03:24 +00:00
kib
75caa7bb1c Document the way to get list of files to process from the stdin.
MFC after:	1 week
Approved by:	kan (mentor)
2006-06-09 16:11:23 +00:00
kib
7c17e7ced2 Copy filename read from the stdin into the private buffer. Otherwise,
next read filename overwrite previous one, resulting in acl being
applied only to the last name in the list.

Submitted by:	Oleg Lomaka <oleg.lomaka at gmail com>
MFC after:	1 week
Approved by:	kan (mentor)
2006-06-09 16:09:26 +00:00
cokane
178c925c64 Fix the wording about the blocksize (-b) parameter. The existing
wording makes it look like pax archives > 32256 bytes are not
POSIX-compliant! Correct this to state that pax archives with
block sizes > 32256 are not POSIX compliant...and settle our fears.

PR:		docs/97059
Reviewed by:	Giorgos Keramidas <keramida>
2006-05-10 20:32:57 +00:00
stefanf
ac3eb05d71 POSIX demands that set's output (when invoked without arguments) should be
sorted.  Sort the variables before printing.

PR:	96415
2006-04-29 12:57:53 +00:00
stefanf
0217b84e8a Check the buffer size when copying the line returned by el_gets() into our
own buffer.  Interactively typing in long lines (>1023 characters)
previously overflowed the buffer.  Unlike the NetBSD people I don't see the
need to subtract 8 from BUFSIZ, so I just used BUFSIZ-1.

Obtained from:	NetBSD
PR:		91110
2006-04-29 10:29:10 +00:00
schweikh
b4b950d049 Whitespace nits. 2006-04-17 17:55:11 +00:00
schweikh
9f61841fa2 Correct assorted grammos and typos. 2006-04-16 11:54:01 +00:00
maxim
d01f82209e o Be pedantic and do fts_close() when done.
PR:		bin/95292
Submitted by:	Charles Hardin
Obtained from:	NetBSD via OpenBSD, PR
2006-04-15 09:26:23 +00:00
schweikh
5eb49ee7ff Output something reasonable for regular and expanded here-documents.
I would have chosen the EOF markers, but they are no longer available
AFAICS, so output "<<HERE" and "<<XHERE" instead.
(NOTE: These changes only affect DEBUG output.)
2006-04-14 13:59:03 +00:00
stefanf
968438f2fc Implement some of the differences between special built-ins and other builtins
demanded by POSIX.
- A redirection error is only fatal (meaning the execution of a shell script is
  terminated) for special built-ins.  Previously it was fatal for all shell
  builtins, causing problems like the one reported in PR 88845.
- Variable assignments remain in effect for special built-ins.
- Option or operand errors are only fatal for special built-ins.
This change also makes errors from 'fc' non-fatal (I could not find any reasons
for this behaviour).

Somewhat independently from the above down-grade the error handling in the
shift built-in if the operand is bigger than $# from an error() call (which is
now fatal) to a return 1.  I'm not sure if this should be considered a POSIX
"operand error", however this change is needed for now as we trigger that error
while building libncurses.  Comparing with other shells, zsh does the same as
our sh before this change (write a diagnostic, return 1), bash behaves as our
sh after this commit (no diagnostic, return 1) and ksh93 and NetBSD's sh treat
it as a fatal error.
2006-04-09 12:21:20 +00:00
gad
20f9416a8f Re-correct commit 1.73, but this time in a way that does not cause
all column-headers to print in lowercase by default.  I was in too
much of a rush in committing 1.75, and didn't notice that the case
had changed.  This time I did considerably more testing, and used
'diff' instead of just quickly eyeballing the results...

Apologies.  I expect this means the dunce cap is mine for awhile.
If this doesn't work, I'll just drop back to 1.72 and hide under
my desk for awhile.
2006-04-06 03:24:31 +00:00
gad
8cc35ce532 Fix a problem introduced by change 1.73, which causes a seg-fault if
the user specifies a keyword which is an alias to some other keyword.
E.g.: stat (for state) or pcpu (for %cpu)..

Submitted by:	Kostik Belousov
MFC plans:	"soon"
2006-04-05 17:40:46 +00:00
stefanf
8d43248fc1 Issue an error when . (dot) is invoked without a filename. The synopsis
is just ". file" according to POSIX, however many other shells allow
arguments to be passed after the file.  For compatibility (we even use that
feature in buildworld) additional arguments are not considered to be an
error, even though this shell does not do anything with the arguments at all.
2006-04-02 18:51:32 +00:00
stefanf
0db401540e Use -s to flag POSIX's "special built-in" utilities in builtins.def. Add a
new member to struct builtincmd and set it to 1 if -s was specified.  This
is done because there are cases where special builtins must be treated
differently from other builtins.

Obtained from:	NetBSD (builtins.def part)
2006-04-02 18:43:33 +00:00
jhb
3ff67ee664 Change the -S and -t options to override each other so that the last one
specified wins to make their interaction less confusing.
2006-03-24 17:09:03 +00:00
jhb
3feffffd98 Fix a bug such that if you enabled sorting by size (-S) and enabled a
flag to use a time other than modtime (-c, -u, or -U), the output would
actually be sorted by the specified time rather than size.  This does
alter the behavior in the case where both -S and -t are specified.  Now,
-S is always preferred.  Previously, -t was preferred if one of -c, -u, or
-U was specified, and -S was preferred otherwise.  Perhaps -S and -t should
override each other (last one specified wins).
2006-03-24 16:47:22 +00:00
jhb
64b8916c3e Add a few more references to -U. 2006-03-24 16:43:58 +00:00
jhb
3d92b82bd8 Add a new -U flag to instruct ls to use the birthtime for printing or
sorting.

Submitted by:	Andrzej Tobola ato at iem dot pw dot edu dot pl
MFC after:	1 week
2006-03-24 16:38:02 +00:00
ru
9e7d2c38b6 Fix spelling. 2006-03-19 19:10:39 +00:00
ru
388e590f95 Reimplementation of world/kernel build options. For details, see:
http://lists.freebsd.org/pipermail/freebsd-current/2006-March/061725.html

The src.conf(5) manpage is to follow in a few days.

Brought to you by:	imp, jhb, kris, phk, ru (all bugs are mine)
2006-03-17 18:54:44 +00:00
rwatson
201a1558c6 Add "-q" argument to getfacl(1), which suppresses the per-file header
comment listing the file name, owner, and group.

MFC after:	1 week
Submitted by:	Jan Srzednicki <w at expro dot pl>
2006-03-13 11:45:29 +00:00
trhodes
eeffa50069 Use .Cm for all key words, not just the ones I added. More in line with
mdoc(7) according to ru.

Requested by:	ru
2006-03-10 12:37:19 +00:00
gad
59d0573b93 Collapse strncpy/strncat/strncat into a single snprintf, as suggested
by pjd.

MFC after:	3 weeks
2006-03-08 09:15:20 +00:00
gad
ec3e08db90 Fix the case where the user specifies an alternate heading for some
output-format keyword, and the keyword they picked is an alias to
some other keyword.                 E.g.:   ps -o stat=Zustand $$
('stat' is defined as an alias for 'state')

PR:		bin/57833
MFC after:	3 weeks
2006-03-08 08:58:44 +00:00
trhodes
e26ef35902 Slightly better markup.
Discussed with:	ru
2006-03-06 10:12:14 +00:00
trhodes
aa556cf7d3 Instead of just hinting at available octets, list some.
Mention that the setting of securelevel may affect one's ability to alter flags.
Xref security.7.
Bump doc date.
2006-03-04 02:38:40 +00:00
cognet
0f32580a80 For pts, print the pts number, instead of the full name. As it was, we ended
up always printing "pts".

Submitted by:	Michal Mertl <mime at traveller dot cz>
2006-02-21 13:02:18 +00:00
ume
30ad96b704 Enable NLS catalog of csh(1).
The tcsh 6.14 uses libiconv to convert catalogs to appropriate charset
dynamically.  However, we don't have libiconv in our tree.  So, I made
some hack to load libiconv dynamically.  If libiconv is available, you
can use catalogs for more locales than the locales which catalog is
actually installed.
To use this feature, you need to symlink catalogs to appropriate
locales.  You can do this by installing ports/shells/tcsh_nls.

Reviewed by:	arch (no objection)
MFC after:	1 week
2006-02-19 06:40:29 +00:00
glebius
e85d27fb5c Add '-F' option which allows to delete existing empty directories, when
creating symbolic links.

PR:		bin/92149
Submitted by:	Eugene Grosbein <eugen grosbein.pp.ru>
2006-02-14 11:08:05 +00:00
schweikh
f4138ecb02 Initialize PWD early on (don't expect it to be inherited from the
environment or set it only when changing directories with cd).

PR:	standards/92640
2006-02-04 14:47:19 +00:00
schweikh
a1b48439af s/staticly/statically/g 2006-02-04 14:41:27 +00:00
schweikh
211f90fcfb s/varable/variable/; s/tored/stored/ 2006-02-04 14:38:37 +00:00
schweikh
627562241f Remove some white space at EOL. 2006-02-04 14:37:50 +00:00
stefanf
5554ab143e Document that '#' starts a comment.
PR:		85103
Submitted by:	garys
Obtained from:	pdksh manual
Patch from:	Daniel Gerzo (with changes by me)
2006-01-01 16:02:12 +00:00
maxim
b2df6a6cc0 o Now when SIG_IGN signal action for SIGCHLD reap zombies
automatically it is possible wait4(2) returns -1 and sets
errno = ECHILD if there were forked children.  A user can
set such signal handler e.g. via ``trap "" 20'', see a PR
for the test case.  Deal with this case and mark a job as
JOBDONE.

PR:		bin/90334
Submitted by:	bde
MFC after:	4 weeks
2005-12-14 17:26:29 +00:00
ru
e279c872b1 [mdoc] add missing space before a punctuation type argument. 2005-12-13 17:07:52 +00:00
stefanf
88baff4d5f - Document trap's -l option and the behaviour of a missing action or a single
dash.
- Discourage the omission of the action.

PR:		70985 [1]
Submitted by:	Martin Kammerhofer
2005-12-08 21:18:59 +00:00
stefanf
0dcfd185af Print empty quotes ('') when an empty string is passed to outqstr().
This makes a difference for the trap builtin, where after "trap '' 0" we
printed "trap -- quit".  This is wrong, because an empty action means to reset
the action to the default.  A side effect of this commit is that empty
variables are now printed as "variable=''" instead of just "variable=".
2005-12-08 21:00:39 +00:00
stefanf
e308dfd964 Correctly quote the output when showing the installed trap actions.
PR:		74043
Submitted by:	Jilles Tjoelker
2005-12-08 20:08:36 +00:00
stefanf
d42177951b Clarify that the echo builtin takes an arbitrary number of strings.
Mention that spaces are printed between the strings.
2005-12-08 17:59:54 +00:00
stefanf
9efed7168d Sort. 2005-12-04 20:01:48 +00:00
stefanf
2df32c17d3 Remove a few commented out builtins from the original ash. The files
implementing them were never part of FreeBSD.
2005-12-04 19:37:07 +00:00
stefanf
5c1966823e Add the times builtin. It reports the user and system time for the shell
itself and its children.  Instead of calling times() (as implied by POSIX) this
implementation directly calls getrusage() to get the times because this is more
convenient.
2005-12-04 18:44:21 +00:00
ru
6bbac1a76d -mdoc sweep. 2005-11-17 12:15:23 +00:00
ru
872d416547 Having three options (-a, -A, -I) controlling the output of dotted
files is too much and hard to follow.  Instead, make the -I option
just mean "do not automatically set -A for root".  That is, if -A
is explicitly set, -I is ignored.  Also, document -I in usage().
(The ls.c diff is better viewed relative to rev. 1.80.)

No objection:	mux
Silence from:	mnag
MFC after:	3 days
2005-11-16 07:13:37 +00:00
mux
8947146b97 Mention the non-standardness of the -I option in ls(1).
Spotted by:	ru
MFC after:	3 days
2005-11-10 14:26:50 +00:00
mux
bb06a78340 Add a -I option to disable the automatic -A flag for the super-user.
PR:		bin/86710
Submitted by:	Marcus Alves Grando
MFC after:	3 days
2005-11-10 00:02:32 +00:00
jcamou
93ee5d4e7b Add local' and return' to the list of built-ins.
Submitted by:	garys
Approved by:	trhodes (mentor)
2005-11-03 00:15:19 +00:00
trhodes
c85026495e Note which options are not part of the standards.
Xref locale(1) and bump document date.

Reviewed by:	keramida
No Objections:	-standards
2005-11-01 19:31:25 +00:00
stefanf
45548c80df Include disabled options in the output of 'set +o'. POSIX says the output of
set +o can be used to reload previous settings, for this to work disabled
options must be printed as well or otherwise options that were set in the mean
time won't be turned off.

To avoid an excessively long output line I formatted the output to print only
six options per line.

Submitted by:	Jilles Tjoelker
PR:		73500
2005-10-29 18:41:35 +00:00
stefanf
a5324897c5 Document command -v and -V.
Glanced at by:	simon
2005-10-29 13:08:35 +00:00
stefanf
9d5c45dd33 Document that read -t timeout returns 1 if the timeout elapses. 2005-10-29 08:22:09 +00:00
stefanf
21aa82a5ae Add the POSIX options -v and -V to the 'command' builtin. Both describe the
type of their argument, if it is a shell function, an alias, a builtin, etc.
-V is more verbose than -v.

PR:	77259, 84539
2005-10-28 18:37:09 +00:00
stefanf
54091cfc82 Protect malloc, realloc and free calls with INT{ON,OFF} directly in chkalloc,
ckrealloc and ckfree (added), respectively.  sh jumps out of the signal handler
using longjmp which is obviously a bad idea during malloc calls.

Note: I think there is still a small race here because volatile sig_atomic_t
only guarantees atomic reads and writes while we're doing increments and
decrements.

Protect a setmode call with INT{ON,OFF} as it calls malloc internally.

PR:		45478
Patch from:	Nate Eldredge
2005-10-28 10:45:19 +00:00
stefanf
267cbf8d22 Use the new name H_SETSIZE instead of the old H_EVENT to set the history
size.

PR:	86355
2005-10-19 15:37:43 +00:00
dougb
1a601e1eb1 Give .Dd a tummy rub, forgotten on my last commit. 2005-09-30 02:12:15 +00:00
dougb
a6ef64df7a Handle the case where the -P flag is specified for a read-only file
earlier, and more gracefully. Previously, this combination would be
ignored early in the code where permissions are tested and fail later
with a very unhelpful "permission denied" error.

Instead, test for this flag in the same block that generates the
"override?" messages for read-only files, but instead of trying
to guess what the user has in mind, generate an error and exit.

Update the man page to reflect this new behavior.

Not objected to by:	freebsd-hackers@
2005-09-29 20:40:29 +00:00
mp
d6a716bd2a Bump up BUFSIZE from 4k to 8k. This was requested by portmgr@ to allow
ports builds in the cluster to work correctly.

Tested by: kris
2005-09-22 18:32:53 +00:00
rwatson
3b28b9c819 Add a "-q" quiet flag to kenv so that warnings can be suppressed.
MFC after:	1 week
2005-09-13 19:01:53 +00:00
stefanf
4ca0c8b501 Elaborate on the behaviour of set -e. 2005-09-10 09:28:39 +00:00
stefanf
c39c1e0d62 Pass the EV_TESTED flag to evalloop() and evalfor(). This fixes unwanted
termination with set -e if a command fails in a loop body inside a function
with an explicitely tested exit status, eg

	f() {
		for i in 1 2 3; do
			false
		done
	}
	f || true

Briefly reviewed by:	cracauer
2005-09-10 08:25:28 +00:00
stefanf
2485a74343 Pass the EV_TESTED flag to the left operand of NSEMI nodes. This fixes
two cases of unwanted termination with set -e:

* if-commands containing several commands separated by semicolons, eg

	if false; false; then [...]

* functions with an explicitely tested exit status that contain a failing
  command which is not the last one, eg

	f() {
		false
		false
	}
	f || true

PR:	77067, 85267
Briefly reviewed by:	cracauer
2005-09-10 08:19:58 +00:00
stefanf
ea5e582b96 Exit the shell if a pipeline that is not preceded by ! fails and set -e is
active.  Use a separate flag to avoid adding another condition to the
if-statement at the end of evaltree().

Briefly reviewed by:	cracauer
2005-09-10 07:41:36 +00:00
stefanf
14d2a8a99c Split the export synopsis into two lines as -p cannot be mixed with variable
names.
2005-09-09 21:06:03 +00:00
stefanf
6a55d3e0eb - Provide a reasonable error message for `export -p var'.
- Use argv rather than argptr since getopt() is used here.
2005-09-09 21:03:34 +00:00
stefanf
37f88a8649 Fix the error message if the mask that is passed to umask -S contains
non-digits.
2005-09-09 19:59:41 +00:00
rse
a339f295af Mention that uuidgen(1) generates DCE version 1 UUIDs only 2005-09-07 07:49:21 +00:00
rse
3a911d4bc8 fix typos: decribed -> described, preceeded -> preceded 2005-09-06 20:14:39 +00:00
rse
fe548cd4fa Various small code cleanups resulting from a code reviewing
and linting procedure:

1. Remove useless sub-expression:

   - if (*start || (!ifsspc && start > string && (nulonly || 1))) {
   + if (*start || (!ifsspc && start > string)) {

   The sub-expression "(nulonly || 1)" always evaluates to true and
   according to CVS logs seems to be just a left-over from some
   debugging and introduced by accident. Removing the sub-expression
   doesn't change semantics and a code inspection showed that the
   variable "nulonly" is also not necessary here in any way (and the
   expression would require fixing instead of removing).

2. Remove dead code:

   -                if (backslash && c == '\\') {
   -                        if (read(STDIN_FILENO, &c, 1) != 1) {
   -                                status = 1;
   -                                break;
   -                        }
   -                        STPUTC(c, p);
   -                } else if (ap[1] != NULL && strchr(ifs, c) != NULL) {
   +                if (ap[1] != NULL && strchr(ifs, c) != NULL) {

   Inspection of the control and data flow showed that variable
   "backslash" is always false (0) when the "if"-expression is
   evaluated, hence the whole block is effectively dead code.
   Additionally, the skipping of characters after a backslash is already
   performed correctly a few lines above, so this code is also not
   needed at all. According to the CVS logs and the ASH 0.2 sources,
   this code existed in this way already since its early days.

3. Cleanup Style:

   - ! trap[signo][0] == '\0' &&
   + ! (trap[signo][0] == '\0') &&

   The expression wants to ensure the trap is not assigned the empty
   string. But the "!" operator has higher precedence than "==", so the
   comparison should be put into parenthesis to form the intended way of
   expression. Nevertheless the code was effectively not really broken
   as both particular NUL comparisons are semantically equal, of course.
   But the parenthesized version is a lot more intuitive.

4. Remove shadowing variable declaration:

   - char *q;

   The declaration of symbol "q" hides another identical declaration of
   "q" in the same context. As the other "q" is already reused multiple
   times and also can be reused again without negative side-effects,
   just remove the shadowing declaration.

5. Just small cosmetics:

   - if (ifsset() != 0)
   + if (ifsset())

   The ifsset() macro is already coded by returning the boolean result
   of a comparison operator, so no need to compare this boolean result
   again against a numerical value. This also aligns the macros usage to
   the remaining existing code.

Reviewed by: stefanf@
2005-09-06 19:30:00 +00:00
rse
4484576c7c fix typo: ommitted -> omitted 2005-09-06 16:08:37 +00:00
stefanf
db33f77468 Print pointers with %p rather than casting them to long. 2005-09-05 17:57:19 +00:00
csjp
549c6812a9 Attempt to complete the userspace integration of POSIX.1e extended ACLs.
This includes adding support for ACLs into cp(1) and mv(1) userspace
utilities.

For mv(1), if _PC_ACL_EXTENDED is in effect for the source AND destination
operands, the destination file's ACLs shall reflect the source.

For cp(1), if _PC_ACL_EXTENDED is in effect for both source and destination
operands, and -p has been specified, the ACLs from the source shall be
preserved on the destination.

MFC after:	1 month
2005-09-05 04:36:08 +00:00
stefanf
50da0d71bf Document that `in word ...' is optional in the for command. 2005-09-03 16:06:04 +00:00
stefanf
f9a3b17353 Return 1 from the unalias builtin if _any_ removal fails, not just the last
one.
2005-09-02 22:43:28 +00:00
stefanf
90dec1edc1 Remove extra getenv() declaration. 2005-09-02 22:28:27 +00:00
stefanf
9426f09a8e Document that unalias can be used to remove several alias names. 2005-09-02 21:15:56 +00:00
garys
a10ff72c17 Improved descriptions of block size handling.
PR:             docs/84765
Submitted by:   garys
Approved by:    keramida
MFC after:      3 days
2005-08-31 17:58:38 +00:00
jcamou
807c0b2541 Wrap a line due to a new sentence.
Noticed by:	simon
Approved by:	trhodes (mentor)
2005-08-29 21:28:12 +00:00
jcamou
d634255a1c o Discuss the ways to escape an alias.
o Fix the alias syntax lines.
o Refer to the Aliases subsection.

PR:		docs/84914
Submitted by:	garys
Approved by:	trhodes (mentor)
MFC after:	3 days
2005-08-29 06:47:43 +00:00
stefanf
5b1426ccf5 Document umask's -S option. 2005-08-17 19:44:15 +00:00
stefanf
95a7612221 Remove a hack for an ancient gdb. 2005-08-15 17:49:38 +00:00
stefanf
a43c6eba96 Recent cleanups made it possible to bump WARNS to 3. 2005-08-14 07:46:56 +00:00
stefanf
d7c6f147cb Put the comparison with PEOF into a new macro is_eof(). Don't use it if the
character comes from a string.
2005-08-13 15:47:13 +00:00
stefanf
e4a640448d Declare echocmd() and testcmd(). 2005-08-13 15:04:30 +00:00
stefanf
9ea5fb8954 Use assignment rather than comparison. 2005-08-13 15:00:54 +00:00
stefanf
810123c2f6 - Provide all initialisers for a struct event.
- Include init.h in the generated init.c.
- Generate prototypes and put the brace on the next line.
2005-08-13 08:38:02 +00:00
stefanf
4aaeb3754a First declare the functions to pacify -Wmissing-prototypes. 2005-08-13 08:31:37 +00:00
stefanf
00771217a6 Include missing headers. 2005-08-13 08:26:58 +00:00
stefanf
75938a7293 Use prototypes in the MKINIT lines collected by mkinit. 2005-08-13 08:12:18 +00:00
stefanf
e015332965 Use prototypes in the generated builtins.{c,h} files. 2005-08-13 08:09:22 +00:00
stefanf
f509d2ea20 cvs -d stefanf@ncvs.FreeBSD.org:/home/ncvs 2005-08-13 07:54:23 +00:00
stefanf
0f8d1315f5 El_parse's third parameter is now const-qualified, add a cast. 2005-08-11 20:28:26 +00:00
stefanf
6abe070f3c Fix a comment.
Submitted by:	Liam J. Foy
2005-08-07 09:11:38 +00:00
phk
92097805fa Don't install examples of NO_EXAMPLES 2005-08-03 09:22:03 +00:00
keramida
8090607544 Spell "protections" correctly. 2005-07-28 18:28:11 +00:00
keramida
b1ddd2636a Spell "background" correctly. 2005-07-28 12:40:23 +00:00
delphij
909e7ff886 Fix a bug when shell expansion is done against dangling symlinks, by
converting the stat() call to a lstat() call, which will cover the
situation.  One can exercise this bug by referring a dangling link with
something like */the-link.

Approved by:	re (scottl)
Submitted by:	Simon 'corecode' Schubert [corecode fs ei tum de]
Obtained from:	NetBSD via DragonFlyBSD (NetBSD rev. 1.51 and DragonFly
		rev. 1.6)
MFC After:	3 days
2005-07-07 18:10:33 +00:00
ru
291174c7f1 Sort sections.
Approved by:	re (blanket)
2005-06-14 08:25:54 +00:00
ru
81411ac5c7 Sorted sections and fixed prompt (PS[12]) strings.
Approved by:	re (blanket)
2005-06-14 08:25:00 +00:00
ru
567c029373 Put the description of the -c option in the right place, as
promised by the Argument List Processing section introduction.
What follows the option in the options list is its long name,
not its argument (as is the case for the -c option).  Also
sort references in the SEE ALSO section.

Approved by:	re (blanket)
2005-06-14 07:50:44 +00:00
des
2bb8de20fe Remove kludges intended to support src trees with partial obj trees.
Discussed with:	ru
2005-06-10 06:12:53 +00:00
dd
fd7de7f99a Remove the EXAMPLES section that describes how to sort by size using
sort(1). This functionality is provided by the -S option now, and it
is useful even though a similar effect is achievable with sort(1),
since the latter doesn't work in combination with -h. This option is
also present in NetBSD, OpenBSD, and GNU fileutils, so there's clearly
a demand for it.

Noticed by:	asmodai
2005-06-03 11:38:35 +00:00
dd
f420c0c650 Improve wording: A sort is "in" a particular order, not "by" a
particular order.
2005-06-03 11:22:06 +00:00
dd
99a2093aa5 Add the -S option to sort files by size. NetBSD and OpenBSD already
have this option with identical semantics (sorting large files first).
-r can be used to reverse the sort if that is desired.

PR:		81625
Submitted by:	Kostas Blekos <mplekos@physics.upatras.gr>, keramida
2005-06-03 11:05:58 +00:00
tjr
af75a9a411 The new name for the DIAGNOSTICS section is EXIT STATUS.
Noticed by:	ru
2005-05-31 12:57:44 +00:00
tjr
0f324ed5e8 Move information about exit status into a DIAGNOSTICS section. 2005-05-29 08:18:48 +00:00
ache
c5682ca184 Fix: printed output flags (onocr) and (onlret) same as oxtabs
PR:             81256
Submitted by:   Arseny Nasokin <tarc@tarc.po.cs.msu.su>
2005-05-26 06:57:57 +00:00
mux
18e53f0af3 Correct a few places where we called warn() when warnx() should have
been used.

Submitted by:	"Liam J. Foy" <liamfoy@sepulcrum.org>
Obtained from:	DragonFlyBSD
2005-05-19 21:33:48 +00:00
gad
2577be2213 A second attempt to adjust option-parsing on a shell command, for the
benefit of scripts start out as:     #!/bin/sh -- # -*- perl -*-
With this fix in place, we can commit a change to kern/imgact_shell.c
so FreeBSD will process the `#!' line in shell-scripts in a more
standard fashion.

PR:		16393
Mentioned on:	freebsd-arch
2005-05-16 04:32:41 +00:00