Commit Graph

3936 Commits

Author SHA1 Message Date
ginsbach 4b5ddda496 df: bump man page date 2021-01-06 20:38:09 +00:00
ginsbach f40edf74af df: add grand total option
Add a grand total option, -c, similar to the du(1) -c option. Adapted from
the same option (-c) in FreeBSD df(1).
2021-01-03 01:43:12 +00:00
mlelstv e5ab0163dd Print real maxrss value like other shells. 2020-10-17 08:46:02 +00:00
christos 883939c9f3 undo previous for 'r' and 'e' modifiers; they should no go further than
the last '/'.
2020-10-02 17:33:13 +00:00
christos e06f645ac3 Fix
% set x='a/b c/d.e'
% echo $x:q:h
2020-09-30 17:51:10 +00:00
msaitoh 57920690e6 s/occurence/occurrence/ 2020-09-29 02:58:51 +00:00
wiz cc550ec026 Remove superfluous Ed. 2020-09-18 07:21:26 +00:00
kre 9d554174da Correct an incorrectly quoted (unquoted, but should be) example used in
the "local" built-in command description (pointed out by mrg@ via uwe@ in
private e-mail).

Add a description to the export command of why this quoting is required,
and then refer to it from local and readonly (explained in export as that
one comes first).

Note that some shells parse export/local/readonly (and often more) as
"declarative" commands, and this quoting isn't needed (provided the
command name is literal and not the result of an expansion) making
X=$Y type args not require quoting, as they often don't in a regular
variable assignment (preceding, or not part of, another command).
POSIX is going to allow, but not require, that behaviour.  We do not
implement it.
2020-09-18 06:48:28 +00:00
wiz 12b01adf5d Mark up path with Pa and use Ev for environment variable. 2020-08-30 20:14:07 +00:00
kre 8ad9ebd911 Since "struct job" gained a pgrp member some time ago now, use it
instead of simply assuming that the pid of the first (leftmost) process
in a pipeline is the pgrp - someday we may switch things around and
create pipelines right to left instead, which has several advantages,
but which would invalidate the assumption which was being made here.
2020-08-30 19:45:05 +00:00
kre 538f77560c Note that negative pid args are permitted (indicating to send to the pgrp
abs(pid)) and indicate that -- is (strictly) needed if the first pid arg
(there often is only one) is negative - though this implementation works
without it if a signal to send has been explicitly given, but whereas
'kill 1234" is valid (send SIGTERM to pid 1234) "kill -1234" will generate
a usage error from the attempt to send signal 1234 to nothing, to send
SIGTERM to pgrp 1234 it needs to be "kill -- -1234" (or "kill -s term -1234").

While here do a couple of markup improvements, and allow for the
possibility that users might be running the builtin kill from some
shell other than csh or sh.
2020-08-30 19:41:39 +00:00
kre 4d4d16423c Every integer that fits within a pid_t is a potential "pid" arg to kill.
That means we cannot use (pid_t)-1 as an error indicator, as that's a
valid pid to use (described as working in kill(1) - yet it wasn't working
in /bin/kill (nor sh's builtin kill, which is essentially the same code).
This is even required to work by POSIX.

So change processnum() (the parser/validator for the pid args) to take
a pointer to a pid_t and return the pid that way, leaving the return value
of the (now int) function to indicate just ok/error.  While here, fix
the validation a little ('' is no longer an accepted alias for 0) and in
case of an error from kill(2) have the error message indicate whether the
kill was targeted at a pid of a pgrp.
2020-08-30 19:35:09 +00:00
kre 075741c09c Use the POSIX specified format if POSIXLY_CORRECT is set in the
environment, rather than the nicer layout that is normally used.

Note this applies to /bin/kill only, the builtin kill in sh uses its
"posix" option for the same purpose, the one in csh only ever uses
POSIX format.
2020-08-30 16:10:40 +00:00
simonb e960fc946b Don't rely on the USPACE kernel define as a fallback if the vm.uspace
sysctl fails.  We've got bigger problems if the sysctl fail anyway.
2020-08-26 10:54:12 +00:00
kre 6a95badd88 Idiot typo, generated by an idiot, fixed by the same one. 2020-08-25 19:42:02 +00:00
ryo d767c6dafe - Bump Size/Used/Avail from 10 to 12, and iUsed/iAvail from 8 to 10 for double-digit terabyte storage.
- set the field width to the optimal, if "-h" is specified.
- if blocksize is greater than M or G, reduce the size field width.
2020-08-21 16:41:06 +00:00
ryo 3a239caa20 field width of blocksize and inode can be changed by #define 2020-08-21 16:40:02 +00:00
wiz 5946912f7b Remove unmatched .El and mark up signal name with Dv. 2020-08-21 08:14:45 +00:00
kre 50794fe6c1 Man page enhancements.
Better describe the command search procedure.
Document "trap -P"
Describe what works as a function name.
More accurate description of reserved word recognition.
Be more accurate about when field splittng happens after
expansions (and in particular note that tilde expansions are
not subject to field splitting).   Be clear that "$@" is
not field split, it simply produces multiple fields as part
of its expansion (hence IFS is irrelevant to this), but if
used as $@ (unquoted) each field produced is potentially subject
to field splitting.   Other minor wording changes.
2020-08-20 23:19:34 +00:00
kre 4a370dce6a Be less conservative about when we do clear_traps() when we have
traps_invalid (that is, when we actually nuke the parent shell's
caught traps in a subshell).  This allows more reasonable use of
"trap -p" (and similar) in subshells than existed before (and in
particular, that command can be in a function now - there can also
be several related commands like
	traps=$(trap -p INT; trap -p QUIT; trap -p HUP)
A side effect of all of this is that
	(eval "$(trap -p)"; ...)
now allows copying caught traps into a subshell environment, if desired.

Also att the ksh93 variant (the one not picked by POSIX as it isn't
generally as useful) of "trap -p" (but call it "trap -P" which extracts
just the trap action for named signals (giving more than one is usually
undesirable).   This allows
	eval "$(trap -P INT)"
to run the action for SIGINT traps, without needing to attempt to parse
the "trap -p" output.
2020-08-20 23:09:56 +00:00
kre 7a2f8a050c Add lots of comments explaining what is happening in here.
Also enhance some of the DEBUG mode trace output (nothing visible
in a normal shell build).

A couple of very minor code changes that no-one should ever notice
(eg: one less wait() call in the case that there is nothing pending).
2020-08-20 23:03:17 +00:00
kre 20122b0e7d Whitespace. NFCI. 2020-08-20 16:15:50 +00:00
kre 36d40de856 For now, probably forever, prohibit unquoted $ and ` in the names of
functions being defined (they can still be included if quoted).

If we parsed the way POSIX specifies (leaving the exact input text of
$ and ` expansions unaltered, until required to be expanded) this would
not be needed, as the name of a function being defined does not underbo
parameter, command, or arith expansions, so xxx$3() { : ; } would just
work.   But for many reasons we don't do that (and are unlikely to ever,
though maintaing both forms might be an option someday) - which led to
very obscure behaviour (if sh were compiled in DEBUG mode, even an abort())
and certainly nothing useful.   So just prohibit these uses for now.
(A portable function name must be a "name" so this makes no difference
at all to posix compat applications/scripts).

A doc update is pending (the updated sh.1 also contains updates in other
areas not yet appropriate to commit).
2020-08-19 22:41:47 +00:00
dholland 00826baa83 Use the right size for several calloc calls.
When allocating for a Char **, it should use sizeof(Char *), not
sizeof(Char **). This doesn't actually affect the results except
on DS9000 though :-)

(part 2, the instance in this file was as far as I can tell
inexplicably missed by CVS on the first go...)
2020-08-09 00:53:38 +00:00
dholland eadef030c6 Clarify some comments. 2020-08-09 00:51:12 +00:00
dholland 7f63690a47 Use the right size for several calloc calls.
When allocating for a Char **, it should use sizeof(Char *), not
sizeof(Char **). This doesn't actually affect the results except
on DS9000 though :-)
2020-08-09 00:34:21 +00:00
dholland 85bd10cb24 Don't cast the value returned from *malloc. No change to compiler output. 2020-08-09 00:22:53 +00:00
kre b95d46c220 Remove a redundant set of parentheses that were added (along with a
extra && or || or something ... forgotten now) as part a failed attempt
to fix an earlier bug (later fixed a better way) - when the extra
test (never committed) was removed, the now-redundant parentheses got
forgotten...

NFC.
2020-08-01 17:56:56 +00:00
kre b76256406d PR bin/55526
Fix a bug that has existed since the "command" command was added in
2003.   "command foo" would cause the definition of a function "foo"
to be lost (not freed, simply discarded) if "foo" is (in addition to
being a function) a filesystem command.   The case where "foo" is
a builtin was handled.

For now, when a function exists with the same name as a filesystem
command, the latter can never appear in the command hash table, and
when used (which can only be via "command foo", just "foo" finds
the function) will always result in a full PATH search.

XXX pullup everything (from NetBSD 2.0 onwards).   (really -8 and -9)
2020-08-01 17:51:18 +00:00
christos 1d895808a5 Fix skipping of directories that begin with a '.' in -R mode.
It is not enough to avoid displaying the contents of the directory,
we need to set FTS_SKIP to avoid descending into any subdirs too.
Otherwise, if a ".foo" directory has a subdirectory "bar", ls will
descend into bar and display its contents. From Todd Miller
2020-07-07 14:29:06 +00:00
riastradh 88d5cead87 Note that -h is an extension to POSIX. Bump date. 2020-06-24 17:00:58 +00:00
riastradh 7f9ee4a0a0 New mv -h option.
`mv -h source target' just issues rename(source, target) without
discriminating on whether target resolves to a directory; this way
you can atomically replace a symlink to a directory.
2020-06-24 16:58:12 +00:00
wiz 7c0103ad20 Sync usage with manpage. 2020-06-18 19:44:01 +00:00
wiz f28f16fcc6 Sort option descriptions. Sort options in SYNOPSIS. Fix xrefs.
Comment out acl(9) which we don't have.
2020-06-18 19:43:53 +00:00
wiz 55f1f0071b Fix xrefs, comment out acl(9) which we don't have. 2020-06-18 19:36:13 +00:00
kamil 784b5b6759 Fix typo 2020-06-11 13:08:07 +00:00
christos c4078bc63f fix reversed test. 2020-05-22 14:54:30 +00:00
joerg 4fc302656d Mark usage as dead 2020-05-22 01:28:44 +00:00
joerg fb222b1585 Don't return from dead functions. 2020-05-22 01:28:00 +00:00
christos f6a91933fb No ACL support for install media (SMALLPROG) 2020-05-17 23:34:11 +00:00
christos 9aa2a9c323 Add ACL support for FFS. From FreeBSD. 2020-05-16 18:31:45 +00:00
msaitoh 8012ca3f0e Remove extra semicolon. 2020-05-14 08:34:17 +00:00
aymeric c79f400cf4 In sink(), upon error, avoid multiple replies to the source as this
would lead to a desynchronization of the protocol and further files or
directories to be ignored or corrupted.

Reported by Daniel Goujot, Georges-Axel Jaloyan, Ryan Lahfa, and David Naccache.
2020-05-06 18:15:40 +00:00
kre fff8f00d1b Bump date for previous change... I frequently forget that bit. 2020-05-06 13:13:50 +00:00
kre 45f67043e6 kill is built-in to more than just csh(1).
While here, add missing Xr sh 1 (which was previously needed, moreso now)
and also include STOP and CONT in the list of common signals.
2020-05-06 09:07:15 +00:00
kre 4685ad7904 Stop forcing the -e option off in the subshell createds for a command
substitution.  This was inherited in the big "-e" fixup patch set (rev 1.50)
of Jan 2000, which came from dash.   dash no longer acts this way.
2020-04-23 09:01:33 +00:00
simonb ccc205ceda Add '-t' option for tcsh-style time output. 2020-04-23 07:54:53 +00:00
joerg e5e328a1f9 Don't depend on common declarations. 2020-04-03 18:11:29 +00:00
joerg 761b9f9565 Don't define max_user_fd in the header. 2020-04-03 16:22:23 +00:00
joerg d79fbfb9e8 Move definition of chdname and do_chroot to options.c 2020-04-03 16:13:32 +00:00