Commit Graph

2364 Commits

Author SHA1 Message Date
Joel Dahl
a303eae7c8 Switch to our preferred license text.
Approved by:	jedgar
2010-03-07 07:59:05 +00:00
Jilles Tjoelker
1749097497 sh: Make sure to popredir() even if a function caused an error. 2010-03-06 17:31:09 +00:00
Jilles Tjoelker
544754df6f sh: Make sure to popredir() even if a special builtin caused an error. 2010-03-06 17:09:22 +00:00
Jilles Tjoelker
c848bc18e8 sh: Improve the command builtin:
* avoid unnecessary fork
* allow executing builtins via command
* executing a special builtin via command removes its special properties

Obtained from:	NetBSD (parts)
2010-03-06 16:57:53 +00:00
Konstantin Belousov
7117b3d5aa Update the list of the process flags. Note that the lists of pending
signals for process and its threads are distinct.

Reviewed by:	jilles
MFC after:	2 weeks
2010-03-05 13:13:35 +00:00
Ulrich Spörlein
55fa734d20 ed(1): make WARNS=6 clean
Although argc and argv are never read after the longjmp is complete,
gcc is not clever enough to see that and needlessly warns about it.
So add volatile to silence the compiler.

Approved by:	ed (the co-mentor, not ed(1))
2010-03-04 16:08:01 +00:00
Joel Dahl
696e61a4da The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Approved by:	pjd
Obtained from:	NetBSD
2010-03-02 07:20:46 +00:00
Konstantin Belousov
c67ea27d10 Do not restrict the allowed signals that can be specified by number
to the list of signals that has symbolic name. It was impossible to
send rt signals with kill(1) due to the check.

MFC after:	1 week
2010-02-25 13:53:09 +00:00
Jaakko Heinonen
774ee54045 Fix expansion of \W in prompt strings when the working directory is "/".
The prompt string was truncated after \W when the working directory was "/".

PR:		bin/89410
Submitted by:	Dr Balwinder Singh Dheeman
MFC after:	1 week
2010-02-24 14:19:56 +00:00
Ulrich Spörlein
2b6974bf61 Bump WARNS where possible.
Checked by:	make universe
Approved by:	ed (co-mentor)
2010-02-15 14:07:40 +00:00
Pawel Jakub Dawidek
7b0706f670 - Implement -q option for pgrep(1).
- Add regression test to test -q option.
2010-02-12 18:52:24 +00:00
Rebecca Cran
c08dcaf147 Initialize the execfile argument to NULL instead of _PATH_DEVNULL. This allows the -M option to be used without specifying -N.
PR:	bin/138146
Approved by:	rrs (mentor)
MFC after:	3 days
2010-02-08 21:23:48 +00:00
Jaakko Heinonen
1fe8c2a989 Make sure that FTS_COMFOLLOW is not set when the -P option is in effect.
Otherwise the -i option will show the inode number of the referenced file
for symbolic links given on the command line. Similarly, the file color
was printed according to the link target in colorized output.

PR:		bin/102394
Reviewed by:	jilles
MFC after:	2 weeks
2010-02-08 15:42:55 +00:00
Warner Losh
ff52ef9533 Tell the compiler these structures are aligned to a byte boundary.
All the elements of these structs are char anyway, so it won't hurt
performance.

Bump warns back up to the default.

# we likely should have CTASSERTS to make sure they are the right size.
# but with libarchive based tar maybe we shouldn't bother.
2010-02-07 17:05:22 +00:00
Jilles Tjoelker
5706357661 sh: Do not stat() $MAIL/$MAILPATH in non-interactive shells.
These may be NFS mounted, and we should not touch them unless we are going
to do something useful with the information.
2010-02-06 22:57:24 +00:00
Warner Losh
6ca3abc9bb Arm doesn't seem to need such kit gloves. Bump the warnings to 3 here
as well.
2010-02-04 07:18:19 +00:00
Jaakko Heinonen
55926a6616 Fixes for ls(1) long format (-l) output:
- Allow -h option to work if the listing contains at least one device
  file.
- Align major and minor device numbers correctly to the size field.

PR:		bin/125678
Approved by:	trasz (mentor)
MFC after:	1 month
2010-01-24 19:23:07 +00:00
Jaakko Heinonen
ba027bbf9a Print full path in the error message. It's possible that fts(3)
provides an empty fts_name and reporting the full path is more
appropriate especially with the -R option.

PR:		bin/107515
Submitted by:	bde
Approved by:	trasz (mentor)
MFC after:	1 week
2010-01-24 19:17:35 +00:00
Ed Schouten
0806dd9238 Remove stale references to utmp(5) and its corresponding filenames.
I removed utmp and its manpage, but not other manpages referring to it.
2010-01-21 17:25:12 +00:00
Ed Schouten
f6d189a9e4 Raise WARNS for various tools where possible.
Submitted by:	Marius Nünnerich <marius@nuenneri.ch>
2010-01-17 21:56:27 +00:00
Gavin Atkinson
f815125fbc Implement an "-x" option to cp(1), for compatibility with Linux and
feature parity with du(1) and similar:  When set, cp(1) will not traverse
mount points.

Initial patch by:       Graham J Lee   leeg teaching.physics.ox.ac.uk

PR:		bin/88056
Initial patch by: Graham J Lee   leeg teaching.physics.ox.ac.uk
Approved by:	ed (mentor)
MFC after:	1 month
2010-01-17 09:37:31 +00:00
Ed Schouten
759dba8c5a Port everything in bin/ from utmp to utmpx.
date: use libc utmpx routines instead of the ones provided by libulog.
pax:  don't depend on <utmp.h>
2010-01-13 17:56:54 +00:00
Ed Schouten
d0632ec94a Let csh(1) use utmpx instead of utmp.
csh allows you to monitor the utmp(x) file to monitor certain user
logins. Unfortunately it needs to directly stat() this file. I don't
want to break this module , but eventually it shouldn't do that. The
idea of the getutxent(3) API is to hide file access.

Approved by:	mp
2010-01-13 17:49:35 +00:00
David E. O'Brien
2a546db853 Committed the wrong version in r201484. This time really fix the "-t"
functionality.  Per the regression tests (pgrep-t.t & pkill-t.t), "-t"
should accept "v1", which means a plain number should be accepted for
UNIX98-style PTY's.
2010-01-04 10:50:17 +00:00
David E. O'Brien
39a60cbcab Fix the "-t" functionality. Per the regression tests (pgrep-t.t & pkill-t.t),
"-t" should accept "v1", which means a plain number should be accepted for
UNIX98-style PTY's.
2010-01-04 10:37:07 +00:00
Jilles Tjoelker
dc82a6f600 sh: Send the "not found" message for builtin <cmd> to redirected fd 2. 2010-01-03 15:01:38 +00:00
Jilles Tjoelker
f7cc73afc8 sh: Fix some bugs with backquoted builtins:
- correctly handle error output in $(builtin 2>&1), clarify out1/out2 vs
  output/errout in the code
- treat all builtins as regular builtins so errors do not abort the shell
  and variable assignments do not persist
- respect the caller's INTOFF

Some bugs still exist:
- expansion errors may still abort the shell
- some side effects of expansions and builtins persist
2010-01-01 18:17:46 +00:00
Jilles Tjoelker
c8054a6197 sh(1): document ulimit -w (swapuse rlimit).
MFC after:	1 week
2009-12-31 22:33:58 +00:00
Jilles Tjoelker
776e6b3332 sh(1): Correct two places where "$@" lacked necessary quotes.
MFC after:	1 week
2009-12-31 22:01:17 +00:00
Jilles Tjoelker
0fb60646df sh: Use PATH= assignment in type.
Example:
  PATH=/var/empty; PATH=/bin type ls
2009-12-31 17:44:24 +00:00
Jilles Tjoelker
06a8a57f82 sh: Allow command -pv and command -pV (lookup using _PATH_STDPATH). 2009-12-31 16:13:33 +00:00
Jilles Tjoelker
92004afed0 sh: Ensure funcnest is decremented if there was an error in the function.
This will be important when things like 'command eval f' will be possible.
Currently, the funcnest = 0 assignment in RESET (called when returning to
the top level after an error in interactive mode) is really sufficient.
2009-12-30 21:46:33 +00:00
Jilles Tjoelker
fe0533fd12 Fix memory leak when parsing backticks (``). 2009-12-30 17:16:49 +00:00
Jilles Tjoelker
63ccda7719 sh: arith: Return only 0 and 1 from && and ||.
This agrees with C, POSIX and other shells.
2009-12-30 15:59:40 +00:00
Ed Schouten
3d65b2f568 Add missing `void' for function without arguments. 2009-12-29 08:45:50 +00:00
Ed Schouten
03929509e5 Add missing `void' for function without arguments. 2009-12-29 08:45:07 +00:00
Antoine Brodin
13e403fdea (S)LIST_HEAD_INITIALIZER takes a (S)LIST_HEAD as an argument.
Fix some wrong usages.
Note: this does not affect generated binaries as this argument is not used.

PR:		137213
Submitted by:	Eygene Ryabinkin (initial version)
MFC after:	1 month
2009-12-28 22:56:30 +00:00
Jilles Tjoelker
c6c5dd37c9 sh: Change varinit to use const better. 2009-12-27 18:32:44 +00:00
Jilles Tjoelker
384aedab58 sh: Various warning fixes (from WARNS=6 NO_WERROR=1):
- const
- initializations to silence -Wuninitialized (it was safe anyway)
- remove nested extern declarations
- rename "index" locals to "idx"
2009-12-27 18:04:05 +00:00
Jilles Tjoelker
d4d5b4ed2d Remove declaration of function that no longer exists. 2009-12-26 13:54:34 +00:00
Edward Tomasz Napierala
6c9c14c5dc Fix breakage introduced in last commit. 2009-12-26 11:03:10 +00:00
Edward Tomasz Napierala
c93b62deca Improve ACL branding mismatch detection and reporting in some rare cases,
such as "setfacl -m ''".
2009-12-26 10:06:45 +00:00
Jilles Tjoelker
29d401c22d sh: Do not run callers' exception handlers in subshells.
Reset the exception handler in the child to main's.

This avoids inappropriate double cleanups or shell duplication when the
exception is caught, such as 'fc' and future 'command eval' and 'command .'.
2009-12-25 20:21:35 +00:00
Jilles Tjoelker
05c10507e9 sh: Do not consider a tilde-prefix with expansions in it.
That is, do not do tilde expansion if any of the CTL* bytes (\201-\210), not
only CTLESC and CTLQUOTEMARK, are encountered. Such an expansion would look
up a user name with sh's internal representation.

The parser does not currently distinguish between backslashed and
unbackslashed \201-\210, so tilde expansion of user names with these bytes
in them is not so easy to fix.
2009-12-25 15:29:18 +00:00
Jilles Tjoelker
95139d9d6a sh: Add some __dead2 to indicate functions that do not return. 2009-12-24 20:55:14 +00:00
Jilles Tjoelker
2cac6e364a sh: Constify various strings.
Most of this is adding const keywords, but setvar() in var.c had to be
changed somewhat more.
2009-12-24 18:41:14 +00:00
Jilles Tjoelker
16d8c5ec5d sh: Remove setting variables from dotcmd/exportcmd.
It is already done by evalcommand(), unless special-ness has been removed,
in which case variable assignments should not persist. (These are currently
always special builtins, but this will change later: command builtin,
command substitution.)

This also fixes a memory leak when calling . with variable assignments.

Example:
  valgrind --leak-check=full sh -c 'x=1 . /dev/null; x=2'
2009-12-24 15:14:22 +00:00
Xin LI
f3ef893ad4 Plug a memory leak.
PR:		bin/141835
Submitted by:	Henning Petersen <henning.petersen t-online.de>
MFC after:	2 weeks
2009-12-21 19:18:27 +00:00
Ed Schouten
9b796f4419 Let date(1) use utmpx instead of logwtmp().
utmpx also has OLD_TIME/NEW_TIME messages, which seem to be intended for
the same purpose as how we call logwtmp() here.
2009-12-05 20:09:50 +00:00
Jilles Tjoelker
e1ef314121 Fix some cases where file descriptors from redirections leak to programs.
- Redirecting fds that were not open before kept two copies of the
  redirected file.
    sh -c '{ :; } 7>/dev/null; fstat -p $$; true'
    (both fd 7 and 10 remained open)
- File descriptors used to restore things after redirection were not
  set close-on-exec, instead they were explicitly closed before executing
  a program normally and before executing a shell procedure. The latter
  must remain but the former is replaced by close-on-exec.
    sh -c 'exec 7</; { exec fstat -p $$; } 7>/dev/null; true'
    (fd 10 remained open)

The examples above are simpler than the testsuite because I do not want to
use fstat or procstat in the testsuite.
2009-11-29 22:33:59 +00:00