Commit Graph

3160 Commits

Author SHA1 Message Date
joerg
14bd6a1392 Make cast warnings for clang non-fatal. 2015-01-29 20:46:31 +00:00
christos
334f5d77c6 Define an undocumented -F option to only use fork instead of vfork for
debugging purposes.
2015-01-02 19:56:20 +00:00
joerg
0bab8dfecf Use l_wmesg if the string is not empty. Don't bother checking l_name for
nullness.
2014-11-15 01:58:34 +00:00
christos
9e91d16823 simplify and eliminate TOCTOU. 2014-10-23 21:03:25 +00:00
jschauma
8e9bed0cec Remove the confusing reference to 'file sizes' in the short description of
the '-l' flag.  As explained in the Long Format section, the total is of
the blocks used by the files, and only applies to directories.
2014-10-18 01:49:01 +00:00
christos
a25724438f PR/48201: Miwa Susumu: Fix set -C (no clobber) for POSIX; from FreeBSD
Can't use O_EXCL because of device nodes; also truncate.
2014-10-15 14:54:25 +00:00
dholland
33586bcc4e Provide real error messages.
Inspired by PR 49169 from David H. Gutteridge, but a much broader patch :-)
2014-09-01 21:42:21 +00:00
christos
5cad352e4f remove unused assignment 2014-08-29 09:35:19 +00:00
christos
d03f4b6b66 Eat trailing backslash like bash and pdksh (not zsh). CBACK+CEOF = TEOF 2014-08-29 09:26:39 +00:00
christos
7de48e21c0 PR/49125: Havard Eidnes: /bin/sh does not support redirecting to or from FDs > 9
According to:
http://pubs.opengroup.org/onlinepubs/009604599/utilities/xcu_chap02.html#tag_02_07

Redirection support for fds > 9 is optional but allowed.
2014-08-19 12:36:58 +00:00
joerg
694cb36aee Fix RCS ID. 2014-08-08 14:48:55 +00:00
dholland
d54dab14a9 remove .if make(install) 2014-07-05 23:13:41 +00:00
dholland
076d336118 remove .if make(install)
these are seriously bad juju
2014-07-05 23:12:33 +00:00
dholland
dcc711d503 Reorg docs, part 2:
Rename the following reference documents to match their programs:
   shell -> sh
   viref -> vi

and rename the following to match their topic better:
   ipctut -> sockets
   ipc -> sockets-advanced

Also, the old "timed" and "timedop" docs are now ref5/timed and
ref8/timed respectively, as the first of these documented the
protocol.
2014-07-05 19:23:00 +00:00
dholland
b7b7574d3b Reorg docs, part 1:
Move all the reference manuals to subdirs of /usr/share/doc/reference.
We have subdirs ref1-ref9, corresponding to man page sections 1-9.

Everything that's the reference manual for a program (sections 1, 6,
8), C interface (sections 2, 3), driver or file system (section 4),
format or configuration (section 5), or kernel internal interface
(section 9) belongs in here.

Section 7 is a little less clear: some things that might go in section
7 if they were a man page aren't really reference manuals. So I'm only
putting things in reference section 7 that are (to me) clearly
reference material, rather than e.g. tutorials, guides, FAQs, etc.
This obviously leaves some room for debate, especially without first
editing the docs with this distinction in mind, but if people hate
what I've done things can always be moved again.

Note also that while roff macro man pages traditionally go in section
7, I have put all the roff documentation (macros, tools, etc.) in one
place in reference/ref1/roff. This will make it easier to find and
also easier to edit it into some kind of coherent form.
2014-07-05 19:22:41 +00:00
dholland
c3ab26950f Rework /usr/share/doc.
Update the <bsd.doc.mk> infrastructure, and update the docs to match
the new infrastructure.

- Build and install text, ps, pdf, and/or html, not roff sources.

- Don't wire the chapter numbers into the build system, or use them in
the installed pathnames. This didn't matter much when the docs were a
museum, but now that we're theoretically going to start maintaining
them again, we're going to add and remove documents periodically and
having the chapter numbers baked in creates a lot of thrashing for no
purpose.

- Specify the document name explicitly, rather than implicitly in a
path. Use this name (instead of other random strings) as the name
of the installed files.

- Specify the document section, which is the subdirectory of
/usr/share/doc to install into.

- Allow multiple subdocuments. (That is, multiple documents in one
output directory.)

- Enumerate the .png files groff emits along with html so they can be
installed.

- Remove assorted hand-rolled rules for running roff and roff widgetry
and add enough variable settings to make these unnecessary. This
includes support for
   - explicit use of soelim
   - refer
   - tbl
   - pic
   - eqn

- Forcibly apply at least minimal amounts of sanity to certain
autogenerated roff files.

- Don't exclude USD.doc, SMM.doc, and PSD.doc directories from the
build, as they now actually do stuff.

Note: currently we can't generate pdf. This turns out to be a
nontrivial problem with no immediate solution forthcoming. So for now,
as a workaround, install compressed .ps as the printable form.
2014-07-05 19:22:02 +00:00
dholland
f86ebf3938 Don't print junk errnos. Avoids:
% ps -tfoo
  ps: /dev/ttyfoo: Undefined error: 0
  Exit 1
2014-06-28 17:32:27 +00:00
christos
f032129312 Adjust to the new alias text libedit API. 2014-06-18 18:17:30 +00:00
wiz
a5aae24aeb Bump date for previous. 2014-06-15 07:27:22 +00:00
dbj
2b213458d4 update list of flags which are extensions to the specification 2014-06-15 07:00:24 +00:00
mrg
26f35dd6b6 remove the build support for GCC 4.1, and any hacks i found for it.
there could still be more -- i only looked for lines matching
both "HAVE_GCC" and "4" as words (grep -w.)
2014-06-13 01:17:45 +00:00
christos
2e317a68f7 PR/48843: Jarmo Jaakkola: Soften the language in the manual page,
making less promises about behavior not explicitly stated in the standard.
2014-06-01 17:46:06 +00:00
christos
01f35fcceb PR/48843: Jarmo Jaakkola: dot commands mess up scope nesting tracking
Evaluation of commands goes completely haywire if a file containing
a break/continue/return command outside its "intended" scope is sourced
using a dot command inside its "intended" scope.  The main symptom is
not exiting from the sourced file when supposed to, leading to evaluation
of commands that were not supposed to be evaluated.  A secondary symptom
is that these extra commands are not evaluated correctly, as some of them
are skipped.  Some examples are listed in the How-To-Repeat section.

According to the POSIX standard, this is how it should work:
    dot:
        The shell shall execute commands from the file in the current
        environment.
    break:
        The break utility shall exit from the smallest enclosing for, while,
        or until loop, [...]
    continue:
        The continue utility shall return to the top of the smallest
        enclosing for, while, or until loop, [...]
    return:
        The return utility shall cause the shell to stop executing
        the current function or dot script.  If the shell is not currently
        executing a function or dot script, the results are unspecified.

It is clear that return should return from a sourced file, which
it does not do.  Whether break and continue should work from the sourced
file might be debatable.  Because the dot command says "in the current
environment", I'd say yes.  In any case, it should not fail in weird
ways like it does now!

The problems occur with return (a) and break/continue (b) because:
    1)  dotcmd() does not record the function nesting level prior to
        sourcing the file nor does it touch the loopnest variable,
        leading to either
    2   a) returncmd() being unable to detect that it should not set
           evalskip to SKIPFUNC but SKIPFILE, or
        b) breakcmd() setting evalskip to SKIPCONT or SKIPBREAK,
        leading to
    3)  cmdloop() not detecting that it should skip the rest of
        the file, due to only checking for SKIPFILE.
The result is that cmdloop() keeps executing lines from the file
whilst evalskip is set, which is the main symptom.  Because
evalskip is checked in multiple places in eval.c, the secondary
symptom appears.
>How-To-Repeat:
Run the following script:

    printf "break\necho break1; echo break2" >break
    printf "continue\necho continue1; echo continue2" >continue
    printf "return\necho return1; echo return2" >return

    while true; do . ./break; done

    for i in 1 2; do . ./continue; done

    func() {
        . ./return
    }
    func

No output should be produced, but instead this is the result:
    break1
    continue1
    continue1
    return1

The main symptom is evident from the unexpected output and the secondary
one from the fact that there are no lines with '2' in them.
>Fix:
Here is patch to src/bin/sh to fix the above problems.  It keeps
track of the function nesting level at the beginning of a dot command
to enable the return command to work properly.

I also changed the undefined-by-standard functionality of the return
command when it's not in a dot command or function from (indirectly)
exiting the shell to being silently ignored.  This was done because
the previous way has at least one bug: the shell exits without asking
for confirmation when there are stopped jobs.

Because I read the standard to mean that break and continue should have
an effect outside the sourced file, that's how I implemented it.  For what
it's worth, this also seems to be what bash does.  Also laziness, because
this way required no changes to loopnesting tracking.  If this is not
wanted, it might make sense to move the nesting tracking to the inputfile
stack.

The patch also does some clean-up to reduce the amount of global
variables by moving the dotcmd() and the find_dot_file() functions from
main.c to eval.c and making in_function() a proper function.
2014-05-31 14:42:18 +00:00
martin
062900c4c2 PR bin/48798: fix format for ino_t.
Slightly modifed variant of the patch provided by Thomas Schmitt.
2014-05-10 09:39:18 +00:00
dholland
a468ec4988 Don't bother using variables whose value is never changed from the
initialization value.
2014-04-20 23:31:40 +00:00
dholland
4e3b1a0bd4 Use an enum type for PRINTMODE vs. WIDTHMODE. Compiler output diffs have
been checked.
2014-04-20 22:48:59 +00:00
christos
318c2b5cda PR/48729: Torbjörn Granlund: Avoid negative index in array ref. 2014-04-11 01:49:45 +00:00
wiz
b0b52b7f33 Wording improvement for previous.
From jmc@OpenBSD via Igor Sobrado.
2014-04-02 19:54:30 +00:00
wiz
ac632886e5 Apply diff from Igor Sobrado <isd@orion.ciencias.uniovi.es>:
We have written a diff to our ls(1) to recover the traditional behaviour
of -f implying -a.  This change does not only accommodates POSIX.1
but also matches traditional UNIX.

OpenBSD commit message:

CVSROOT:        /cvs
Module name:    src
Changes by:     sobrado@cvs.openbsd.org 2014/03/31 14:54:37

Modified files:
        bin/ls         : ls.1 ls.c

Log message:
restore the traditional behavior of -f implying -a; apparently Keith Bostic
forgot to restore it when the -f flag was put back on 2nd of September 1989,
after being removed on 16th of August as a consequence of issues getting it
working over NFS, so deviation from traditional UNIX behavior in all BSDs
looks like an historical accident; as a side effect, this change accommodates
behavior of this option to IEEE Std 1003.1-2008 (``POSIX.1'').

joint work with jmc@ (who found the inaccuracy in our implementation),
schwarze@ (who provided a detailed tracking of historical facts) and millert@

ok millert@, schwarze@
2014-04-02 10:55:47 +00:00
christos
e8c3f5b299 PR/48692: Henning Petersen: Missplaced paranthesis in bin/ed gbl.c and main.c 2014-03-31 12:55:46 +00:00
joerg
f18d1e6774 Use __printflike. 2014-03-25 17:23:37 +00:00
dholland
c4044741ea don't use sprintf 2014-03-23 05:07:59 +00:00
dholland
a3542600fb sprintf considered harmful 2014-03-23 05:06:42 +00:00
mlelstv
fa4d72b17c fix -w output 2014-02-22 13:11:42 +00:00
mlelstv
d85eb2bfe0 add u option to getopt again. 2014-02-22 13:08:13 +00:00
christos
c7dda21c10 Add -X (don't cross mount points when recursing) from tls@ 2014-02-21 02:42:41 +00:00
wiz
9a4a31623a Use .Nm for 'ls'. 2014-02-20 19:10:25 +00:00
christos
0c47a5c376 Add -O (only leaf files) and -P (print full path), from tls@ 2014-02-20 18:56:36 +00:00
dsl
dc210c7fbd Remove some pointless inclusions os sys/user.h 2014-02-19 20:42:14 +00:00
elric
b760f10513 Remove options added in 1.18, commitid: UhxHPgtT2Pzeg4Yw due to some
level of controversy about their inclusion.
2014-02-13 12:00:29 +00:00
christos
1468e9a310 explain why forks fail 2014-01-26 22:38:20 +00:00
roy
7969ec4d55 Add wctype(3) support to Shell Patterns.
Obtained from FreeBSD.
2014-01-20 14:05:51 +00:00
wiz
2161b7b1e3 Bump date for previous. 2014-01-15 09:24:31 +00:00
mlelstv
067314c61e Make ps -s use LTIME instead of TIME in the default output format. 2014-01-15 08:09:10 +00:00
mlelstv
b3dffa81d5 Add an LTIME column that prints lwp cputime. 2014-01-15 08:07:53 +00:00
christos
bc1be752a1 whitespace fixes 2014-01-01 19:50:44 +00:00
christos
316fbf0f9f There was a case where \n did not increase plinno 2014-01-01 19:06:45 +00:00
christos
87802d4338 clarify further. 2014-01-01 18:29:39 +00:00
christos
724ab0808b explain the previous fix. 2014-01-01 16:55:28 +00:00
christos
9bcdabb166 allow case statement without any patterns. 2013-12-31 22:53:57 +00:00