summaryrefslogtreecommitdiffstats
path: root/bin
Commit message (Collapse)AuthorAgeFilesLines
* Let date(1) use utmpx instead of logwtmp().ed2009-12-052-5/+11
| | | | | utmpx also has OLD_TIME/NEW_TIME messages, which seem to be intended for the same purpose as how we call logwtmp() here.
* Fix some cases where file descriptors from redirections leak to programs.jilles2009-11-292-16/+7
| | | | | | | | | | | | | | | | - 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.
* Fix various things about SIGINT handling:jilles2009-11-226-6/+25
| | | | | | | | | | | | | | | | | | * exception handlers are now run with interrupts disabled, which avoids many race conditions * fix some cases where SIGINT only aborts one command and continues the script, in particular if a SIGINT causes an EINTR error which trumped the interrupt. Example: sh -c 'echo < /some/fifo; echo This should not be printed' The fifo should not have writers. When pressing ctrl+c to abort the open, the shell used to continue with the next command. Example: sh -c '/bin/echo < /some/fifo; echo This should not be printed' Similar. Note, however, that this particular case did not and does not work in interactive mode with job control enabled.
* sh: Ensure the same command input file is on top after executing a builtin.jilles2009-11-223-0/+33
| | | | | | | | | | | | | This avoids weirdness when 'fc -e vi' or the like is done and there is a syntax error in the file. Formerly an interactive shell tried to execute stuff after the syntax error and exited. This should also avoid similar issues with 'command eval' and 'command .' when 'command' is implemented properly as in NetBSD sh. Special builtins did not have this problem since errors in them cause the shell to exit or to reset various state such as the current command input file.
* trap: do not consider a bad signal name a fatal error.jilles2009-11-211-3/+6
| | | | | POSIX explicitly prescribes this. Continue processing any other signals and return status 1.
* Handle current work directories of arbitrary length. The argument to cdstefanf2009-11-211-22/+29
| | | | | | | continues to be limited by PATH_MAX (1024). Obtained from: NetBSD PR: 104456
* sh: Some changes to stderr flushing:jilles2009-11-217-14/+16
| | | | | | | | | * increase buffer size from 100 to 256 bytes * remove implied flush from out2str(), in particular this avoids unnecessary flushing in the middle of a -x tracing line * rename dprintf() to out2fmt_flush(), make it flush out2 and use this function in various places where flushing is desired after an error message
* Add pwait utility, which waits for any process to terminate.jilles2009-11-174-0/+229
| | | | | | | | | | | This is similar to the Solaris utility of the same name. Some use cases: * rc.subr's wait_for_pids * interactive use, e.g. to shut down the computer when some task is done even if the task is already running Discussed on: hackers@
* Fix small resource leak (memory).netchild2009-11-171-0/+1
| | | | | Reviewed by: gad MFC after: 1 week
* sh: Allow a newline before "in" in a for command, as required by POSIX.jilles2009-11-141-1/+3
|
* sh: Use sigaction instead of signal/siginterrupt combination.jilles2009-11-111-4/+6
|
* sh: Fix memory leak when using a variable in arithmetic like $((x)).jilles2009-11-051-3/+23
| | | | MFC after: 3 weeks
* Increase width for %CPU, RSS and VSZ columns for now. Modern systemsdelphij2009-11-031-3/+3
| | | | tend to have larger memory, larger process, and more CPU.
* Use our canonical .Dd format.brueffer2009-11-021-1/+1
| | | | Submitted by: Ulrich Spoerlein
* sh: Exempt $@ and $* from set -ujilles2009-10-242-3/+6
| | | | | | | | This seems more useful and will likely be in the next POSIX standard. Also document more precisely in the man page what set -u does (note that $@, $* and $! are the only special parameters that can ever be unset, all the others are always set, although they may be empty).
* Check error of dlfunc(3).ume2009-10-171-0/+11
| | | | MFC after: 3 days
* sh: Show more information about syntax errors in command substitution:jilles2009-10-161-0/+5
| | | | | | | the line number where the command substitution started. This applies to both the $() and `` forms but is most useful for `` because the other line number is relative to the enclosed text there. (For older versions, -v can be used as a workaround.)
* Removed redundant WARNS setting.ru2009-10-152-2/+0
| | | | Submitted by: Ulrich Spörlein
* ls: Make -p not inhibit following symlinks.jilles2009-10-131-1/+1
| | | | | | | | | According to the man page, when neither -H/-L nor -F/-d/-l are given, -H is implied. This agrees with POSIX, GNU ls and Solaris ls. This means that -p, although it is very similar to -F, does not prevent the implicit following of symlinks. PR: standards/128546
* Clarify quoting of word in ${v=word} in sh(1).jilles2009-10-071-0/+3
|
* sh: Send the "xyz: not found" message to redirected fd 2.jilles2009-10-062-7/+3
| | | | | | | | | | This also fixes that trying to execute a non-regular file with a command name without '/' returns 127 instead of 126. The fix is rather simplistic: treat CMDUNKNOWN as if the command were found as an external program. The resulting fork is a bit wasteful but executing unknown commands should not be very frequent. PR: bin/137659
* sh: Disallow mismatched quotes in backticks (`...`).jilles2009-10-011-7/+1
| | | | | | | | | Due to the amount of code removed by this, it seems that allowing unmatched quotes was a deliberate imitation of System V sh and real ksh. Most other shells do not allow unmatched quotes (e.g. bash, zsh, pdksh, NetBSD /bin/sh, dash). PR: bin/137657
* Mention that NUL characters are not allowed in sh(1) input.jilles2009-09-201-0/+4
| | | | | | | | I do not consider this a bug because POSIX permits it and argument strings and environment variables cannot contain '\0' anyway. PR: bin/25542 MFC after: 2 weeks
* Add NFSv4 support to setfacl(1).trasz2009-09-076-221/+539
| | | | Reviewed by: rwatson
* Add NFSv4 ACL support to mv(1).trasz2009-09-041-12/+58
| | | | Reviewed by: rwatson
* Add NFSv4 ACL support to getfacl(1).trasz2009-09-042-17/+72
| | | | Reviewed by: rwatson
* Fix regression introduced in r196712 - the 'name' string needstrasz2009-09-021-5/+9
| | | | | | to be rewritten for each file we want to check ACL on. Without this change, ls(1) would check only the ACL on the first file to list.
* Add NFSv4 ACL support to cp(1) and fix a few memory leaks.trasz2009-09-021-30/+93
| | | | | | | | | Note that this changes error reporting behaviour somewhat - before, no error was reported if ACL couldn't be copied because the target filesystem doesn't support ACLs. Now, it will be reported - of course, only if there actually is an ACL to copy. Reviewed by: rwatson
* - Don't include both <sys/types.h> and <sys/param.h>trasz2009-09-021-9/+6
| | | | | | | | | | | | | | - Keep variables sorted - Fix logic error with -f and -v options - don't print the usual -v output if there was an error, whether or not we were passed -f - Don't call free(3) just before exit(2) - Whitespace fixes Submitted by: bde
* Add NFSv4 ACL support to ls(1).trasz2009-08-311-52/+54
|
* Make the code more readable and fix chmod(1) on symlinks withtrasz2009-08-311-13/+15
| | | | NFSv4 enabled.
* sh: Fix crash with empty functions (f() { }) introduced in r196483jilles2009-08-284-8/+17
| | | | | | | | | | | | Empty pairs of braces are represented by a NULL node pointer, just like empty lines at the top level. Support for empty pairs of braces may be removed later. They make the code more complex, have inconsistent behaviour (may or may not change $?), are not specified by POSIX and are not allowed by some other shells like bash, dash and ksh93. Reported by: kan
* sh: Fix crash when undefining or redefining a currently executing function.jilles2009-08-235-18/+44
| | | | | | | | Add a reference count to function definitions. Memory may leak if multiple SIGINTs arrive in interactive mode, this will be fixed later by changing SIGINT handling. PR: bin/137640
* Add the -d switch to the usage message.brian2009-07-231-1/+1
| | | | | | Submitted by: Emil Mikulic - emil at dmr dot ath dot cx Approved by: re (kib) MFC after: 1 week
* Allow creating hard links to symlinks using ln(1).jilles2009-07-192-22/+41
| | | | | | | | This implements the POSIX.1-2008 -L and -P flags. The default remains to create hard links to the target of symlinks. Approved by: re (kib), ed (mentor)
* Add manual page links to advertise procstat(1) a little better.trasz2009-07-091-1/+2
| | | | Approved by: re (kib)
* With NFSv4 ACLs, it is possible that applying a mode to an ACL whichtrasz2009-07-011-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | is identical to the mode computed from that ACL will modify the ACL. For example, mode computed from the following ACL is 0600: user:kamila:rwx--------C--:------:allow owner@:--x-----------:------:deny owner@:rw-p---A-W-Co-:------:allow group@:rwxp----------:------:deny group@:--------------:------:allow everyone@:rwxp---A-W-Co-:------:deny everyone@:------a-R-c--s:------:allow However, applying that mode (chmod 0600) changes the ACL into this: user:kamila:rwx-----------:------:deny user:kamila:rwx--------C--:------:allow owner@:--x-----------:------:deny owner@:rw-p---A-W-Co-:------:allow group@:rwxp----------:------:deny group@:--------------:------:allow everyone@:rwxp---A-W-Co-:------:deny everyone@:------a-R-c--s:------:allow In chmod(1) utility, there is an optimisation, which makes it not call chmod(2) if the mode of the file is the same as the new mode. Disable that optimisation for files which may have NFSv4 ACLs. Reviewed by: rwatson Approved by: re (kib)
* Fix some weirdnesses in the NetBSD IFS code,jilles2009-06-251-2/+3
| | | | | | | | in particular "$@"$ifschar if the final positional parameter is empty. With the NetBSD code, adding the $ifschar removes a parameter. PR: standards/79067 Approved by: ed (mentor) (implicit)
* Improve IFS expansion using code from NetBSD.jilles2009-06-251-61/+80
| | | | | | | | We now pass the ifs.sh testsuite. PR: standards/79067 Approved by: ed (mentor) (implicit) Obtained from: NetBSD
* Designate special builtins as such in command -V and type.jilles2009-06-242-3/+15
| | | | | | Also document various properties of special builtins that we implement. Approved by: ed (mentor) (implicit)
* Staticify internal routines.delphij2009-06-234-7/+7
|
* Quote -x tracing output so it is unambiguous.jilles2009-06-231-2/+17
| | | | | | It is usually but not always suitable for re-input to the shell. Approved by: ed (mentor) (implicit)
* Do not fork for a subshell if it is the last thing this shell is doingjilles2009-06-231-2/+2
| | | | | | | | | | | | | | | | | | | | | (EV_EXIT). The fork is still done as normal if any traps are active. In many cases, the fork can be avoided even without this change by using {} instead of (), but in practice many scripts use (), likely because the syntax is simpler. Example: sh -c '(/bin/sleep 10)& sleep 1;ps -p $! -o comm=' Now prints "sleep" instead of "sh". $! is more useful this way. Most shells (dash, bash, pdksh, ksh93, zsh) seem to print "sleep" for this. Example: sh -c '( ( ( (ps jT))))' Now shows no waiting shell processes instead of four. Most shells (dash, bash, pdksh, ksh93, zsh) seem to show zero or one. PR: bin/74404 Approved by: ed (mentor) (implicit)
* Usermode portion of the support for swap allocation accounting:kib2009-06-231-1/+1
| | | | | | | | | | | - update for getrlimit(2) manpage; - support for setting RLIMIT_SWAP in login class; - addition to the limits(1) and sh and csh limit-setting builtins; - tuning(7) documentation on the sysctls controlling overcommit. In collaboration with: pho Reviewed by: alc Approved by: re (kensmith)
* sh: Improve handling of setjmp/longjmp volatile:jilles2009-06-234-61/+18
| | | | | | | | | | | - remove ineffective and unnecessary (void) &var; [1] - remove some unnecessary volatile keywords - add a necessary volatile keyword - save the old handler before doing something that could use the saved value Submitted by: Christoph Mallon [1] Approved by: ed (mentor)
* Fix race condition in noclobber option.jilles2009-06-201-7/+19
| | | | | | | | | | Formerly, it was possible for the file to be created between the check if it existed and the open; the contents would then be lost. Because this must use O_EXCL, noclobber > will not create a file through a symlink anymore. This agrees with behaviour of other shells. Approved by: ed (mentor) (implicit)
* Fix some issues with quoted output and shorten it in some cases.jilles2009-06-191-9/+15
| | | | | | | | | | | | | | Output quoted suitable for re-input to the shell occurs in various cases such as 'set', 'trap'. Bugfix: *, ? and [ must be quoted (except sole [) Bugfix: ~ and # must be quoted (really only sometimes, but keep it simple) Bugfix: space, tab and newline must always be quoted Shortening: other IFS characters do not need quoting Bugfix: send to correct output file, not hard-coded stdout Shortening: avoid unnecessary '' with \' Approved by: ed (mentor)
* Properly flush input after an error in backquotes in interactive mode.jilles2009-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | For parsing an old-style backquote substitution (`...`), a string "file" is used to store the contents of the substitution (with the special backslash processing done). If an error occurs, the shell cleans up all these files (returning to the top level) and flush the top level file. Erroneously, it first flushed the current file and then cleaned up all extra files, so that the top level file (i.e. the terminal) was not flushed. Example (in interactive mode): echo `for` echo This should not be printed Also noticeable in (in interactive mode): echo `(` The old version prints an extraneous prompt. Approved by: ed (mentor)
* Avoid leaving unnecessary waiting shells in many forms of sh -c COMMAND.jilles2009-06-135-9/+35
| | | | | | | | | | | | | | | | | | | | | | This change only affects strings passed to -c, when the -s option is not used. The approach is to check if there may be additional data in the string after parsing each command. If there is none, use the EV_EXIT flag so that a fork may be omitted in specific cases. If there are empty lines after the command, the check will not see the end and forks will not be omitted. The same thing seems to happen in bash. Example: sh -c 'ps lT' No longer shows a shell process waiting for ps to finish. PR: bin/113860 Reviewed by: stefanf Approved by: ed (mentor)
* Don't skip forking for an external command if any traps are active.jilles2009-06-133-1/+17
| | | | | | | | | | | | | | | | | Example: sh -c '(trap "echo trapped" EXIT; sleep 3)' now correctly prints "trapped". With this check, it is no longer necessary to check for -T explicitly in that case. This is a useful bugfix by itself and also important because I plan to skip forking more often. PR: bin/113860 (part of) PR: bin/74404 (part of) Reviewed by: stefanf Approved by: ed (mentor)
OpenPOWER on IntegriCloud