summaryrefslogtreecommitdiffstats
path: root/bin/sh/miscbltin.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove some white space at EOL.schweikh2006-02-041-1/+1
|
* Protect malloc, realloc and free calls with INT{ON,OFF} directly in chkalloc,stefanf2005-10-281-0/+2
| | | | | | | | | | | | | | 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
* Fix the error message if the mask that is passed to umask -S containsstefanf2005-09-091-1/+1
| | | | non-digits.
* Various small code cleanups resulting from a code reviewingrse2005-09-061-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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@
* First declare the functions to pacify -Wmissing-prototypes.stefanf2005-08-131-0/+4
|
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* - Don't use quad_t when we really mean rlim_t.mux2002-10-011-5/+6
| | | | | | | | - Cast rlim_t to intmax_t when printing it. This should fix the last format errors in sh(1). Tested on: i386, sparc64
* Callers of error() don't need to supply a program name prefix in thetjr2002-09-301-6/+6
| | | | error message. Stops ulimit giving error messages like "ulimit: ulimit: xyz".
* Consistently use FBSDIDobrien2002-06-301-2/+2
|
* Add support for RLIMIT_VMEM. The #ifdef's were already there but getopt()dillon2002-06-261-1/+1
| | | | needed to be adjusted.
* o __P has been reovedimp2002-02-021-9/+3
| | | | | | | | | | | | | | | | | | o Old-style K&R declarations have been converted to new C89 style o register has been removed o prototype for main() has been removed (gcc3 makes it an error) o int main(int argc, char *argv[]) is the preferred main definition. o Attempt to not break style(9) conformance for declarations more than they already are. o Change int foo() { ... to int foo(void) { ...
* Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. Thesheldonh2001-07-261-2/+2
| | | | | | | definitions are more readable, and it's possible that they're more portable to pathalogical platforms. Submitted by: David Hill <david@phobia.ms>
* Fix warnings, some of them serious because sh violated namecracauer2000-04-201-6/+3
| | | | | | | | spaces reserved by the header files it includes. mkinit.c still produces C code with redundant declarations, although they are more harmless since they automatically derived from the right places.
* Implement ulimit -b for RLIMIT_SBSIZE.green1999-10-091-1/+4
|
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* Make the behaviour of `read -e', ie. treating backslashes as special,tg1999-08-261-8/+10
| | | | | | | the default. Add -r option for the read builtin to reverse this. PR: 13274 Reviewed by: cpiazza, hoek, sheldonh
* Various spelling/formatting changes.kris1999-05-081-2/+2
| | | | Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
* Free memory from setmode.imp1998-12-161-2/+3
| | | | Obtained from: OpenBSD
* Improve bookkeeping of in_waitcmd and style fixes.cracauer1998-08-251-2/+2
| | | | Submitted by: Bruce Evans
* Do not exit on SIGINT in non-interactive shells, fixes PR 1206,cracauer1998-08-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | i.e. this makes emacs usable from system(3). Programs called from shellscripts are now required to exit with proper signal status. That means, they have to kill themself. Exiting with faked numerical exit code is not sufficient. Exit with proper signal status if script exits on signal. Make the wait builtin interruptable, both with and without traps set. Use volatile sig_atomic_t where (and only where) appropriate. (Almost) fix printing of newlines on SIGINT. Make traps setable from trap handlers. This is needed for shellscripts that catch SIGINT for cleanup work but intend to exit on it, hance have to kill themself from a trap handler. I.e. mkdep. While I'm at it, make it -Wall clean. -Wall is not enabled in Makefile, since vararg warnx() macro calls in usr.bin/printf/printf.c are not -Wall-able. PR: 1206 Obtained from: Basic SIGINT fix from Bruce Evans
* Add rcsid. Spelling.charnier1998-05-181-3/+5
|
* Add the '-t timeout' option to the 'read' builtin. This allows themsmith1997-09-291-4/+63
| | | | | | | | 'read' command to return an error if the user fails to supply any input withink a given time period. The behaviour of this option is similar to that of the like-named option in ksh93. Reviewed by: joerg
* Use the __unused attribute where warranted.steve1997-05-191-6/+6
|
* Nuke register keyword usage and #if -> #ifdef.steve1997-04-281-2/+2
| | | | Obtained from: NetBSD
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Merge in NetBSD mods and -Wall cleaning.steve1996-12-141-13/+11
| | | | Obtained from: NetBSD, me
* eek, how did that happen? I must have committed something left over frompeter1996-09-031-4/+4
| | | | when I was experimenting looking for an alternate format. *blush*
* Fix for PR#1287. This makes sh behave sensibly in case statements in thepeter1996-09-031-4/+5
| | | | | | | | | | | | | | face of aliases. Note, bash doesn't do aliases while running scripts, but "real" ksh does.. Also: Reduce redundant .Nm macros in (unused) bltin/echo.1 nuke error2, it's hardly used. More -Wall cleanups dont do certain history operations if NO_HISTORY defined handle quad_t's from resource limits Submitted by: Steve Price <sprice@hiwaay.net> (minor tweaks by me)
* Misc cleanups and fixes from Bruce:peter1996-09-031-22/+33
| | | | | | | | | | - don't put \n on error() calls, error adds it already. - don't prepend "ulimit" on error() calls in miscbltin.c. - getopt typo on ulimit -p -> -u conversion - get/setrlimit() calls were not being error checked ulimit formatting cleanup from me, use same wording as bash on Bruce's suggestion. Add ulimit arg to output on Joerg's suggestion.
* Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is apeter1996-09-011-208/+216
| | | | | | | | | | | | | | merge of parallel duplicate work by Steve Price and myself. :-] There are some changes to the build that are my fault... mkinit.c was trying (poorly) to duplicate some of the work that make(1) is designed to do. The Makefile hackery is my fault too, the depend list was incomplete because of some explicit OBJS+= entries, so mkdep wasn't picking up their source file #includes. This closes a pile of /bin/sh PR's, but not all of them.. Submitted by: Steve Price <steve@bonsai.hiwaay.net>, peter
* o rename ulimit -p into ulimit -u, so we are in agreement with bashjoerg1995-10-211-4/+4
| | | | | | | o fix brokeness for 1>&5 redirection, where `5' was an invalid file descriptor, but no error message has been generated o fix brokeness for redirect to/from myself case
* Implement the "ulimit" builtin. This is the analogon to csh's "limit"joerg1995-10-191-1/+214
| | | | | | | | | command and badly needed in sh(1) for everybody who wants to modify the system-wide limits from inside /etc/rc. The options are similar to other system's implemantations of this command, with the FreeBSD additions for -m (memoryuse) and -p (max processes) that are not available on other systems.
* Added $Id$dg1994-09-241-0/+2
|
* BSD 4.4 Lite bin Sourcesrgrimes1994-05-261-0/+166
OpenPOWER on IntegriCloud