summaryrefslogtreecommitdiffstats
path: root/bin/sh
Commit message (Collapse)AuthorAgeFilesLines
* sh: Remove two redundant (uintmax_t) casts.jilles2014-08-201-3/+2
| | | | Submitted by: jmallett
* sh: Avoid overflow in atoi() when parsing HISTSIZE.jilles2014-08-171-2/+3
| | | | | Side effect: a non-numeric HISTSIZE now results in the default size (100) instead of 0.
* sh: Reject integer overflow in number and is_number.jilles2014-08-171-3/+11
|
* sh: Don't hardcode relative paths in the tests stderr files.jilles2014-08-1711-17/+11
| | | | | | | | These paths have had to be adjusted to changes in the testsuite runner several times, so modify the tests to remove the need for such adjustment. A cp in functional_test.sh is now unneeded, but this matters little in performance.
* sh: Mask off shift distance (<< and >>) in arithmetic.jilles2014-08-153-2/+44
| | | | | | | | | | | In C, shift distances equal to or larger than the number of bits in the operand result in undefined behaviour. As part of eliminating undefined behaviour in arithmetic, mask off the distance like Java and JavaScript specify and C on x86 usually does. Assumption: conversion from unsigned to signed retains the two's complement bits. Assumption: uintmax_t has no padding bits.
* Convert bin/sh/tests to ATFngie2014-08-1315-82/+127
| | | | | | | | | | | | | The new code uses a "test discovery mechanism" to determine what tests are available for execution The test shell can be specified via: kyua test -v test_suites.FreeBSD.bin.sh.test_shell=/path/to/test/sh Sponsored by: EMC / Isilon Storage Division Approved by: jmmv (mentor) Reviewed by: jilles (maintainer)
* sh: Allow arbitrarily large numbers in break and continue.jilles2014-07-203-1/+18
| | | | The argument is capped to loopnest, so strtol()'s [ERANGE] can be ignored.
* sh: Remove prefix() function. Use strncmp() instead.jilles2014-07-204-18/+5
|
* sh: Deduplicate some code in ulimit builtin.jilles2014-07-191-27/+25
|
* Replace all uses of libncurses and libtermcap with their wide characterbrooks2014-07-171-2/+2
| | | | | | | | | | variants. This allows usable file system images (i.e. those with both a shell and an editor) to be created with only one copy of the curses library. Exp-run: antoine PR: 189842 Discussed with: bapt Sponsored by: DARPA, AFRL
* sh: Correctly handle positional parameters beyond INT_MAX on 64-bit systems.jilles2014-07-123-2/+19
| | | | | | | | | | | | | Currently, there can be no more than INT_MAX positional parameters. Make sure to treat all higher ones as unset to avoid incorrect results and crashes. On 64-bit systems, our atoi() takes the low 32 bits of the strtol() and sign-extends them. On 32-bit systems, the call to atoi() returned INT_MAX for too high values and there is not enough address space for so many positional parameters, so there was no issue.
* sh: Consistently treat ${01} like $1.jilles2014-07-123-7/+11
| | | | | Leading zeroes were ignored when checking whether a positional parameter is set, but not when expanding its value. Ignore leading zeroes in any case.
* sh: Add test for ${01} and ${010} that already works.jilles2014-07-082-0/+5
| | | | | | | | Although it is probably unwise to use this, POSIX is clear that leading zeroes are permitted in positional parameters (and do not indicate octal). Such positional parameters are checked for being unset and/or null correctly, but their value is incorrectly expanded.
* Don't install locale1.0 if MK_NLS == no.jilles2014-07-081-0/+2
| | | | | | | | | | | | The test locale1.0 depends on locale support; it is meaningless without a working LC_MESSAGES. I added an OptionalObsoleteFiles.inc entry. PR: 181151 Submitted by: Garrett Cooper (original version) MFC after: 1 week Sponsored by: EMC / Isilon Storage Division
* sh: Fix overflow checking on 'ulimit' operand.jilles2014-07-051-10/+14
|
* sh: Avoid undefined behaviour shifting negative values left in arithmetic.jilles2014-06-011-1/+1
| | | | With i386 base clang, arith_yacc.o remains unchanged.
* sh: Simplify find_command() slightly.jilles2014-05-311-7/+5
|
* sh: In getopts, unset OPTARG where POSIX says we should.jilles2014-05-104-13/+26
|
* sh: Add new tests to the Makefile.jilles2014-05-101-0/+2
|
* sh: Don't discard getopts state on unknown option or missing argument.jilles2014-05-103-8/+17
| | | | | | | When getopts finds an invalid option or a missing option-argument, it should not reset its state and should set OPTIND as normal. This is an old ash bug that was fixed long ago in dash. Our behaviour now matches most other shells.
* sh: Send getopts error messages to stderr, not stdout.jilles2014-05-092-3/+3
| | | | Adjust a testcase for this change.
* sh: Add more necessary INTOFF/INTON.jilles2014-05-092-0/+6
|
* sh: Add some tests for normal use of getopts.jilles2014-05-074-0/+29
|
* Use src.opts.mk in preference to bsd.own.mk except where we need stuffimp2014-05-061-1/+1
| | | | from the latter.
* sh: Fix memory leak with an assignment before a regular builtin.jilles2014-03-271-2/+8
| | | | MFC after: 1 week
* sh: Fix memory leak when trying to set a read only variable.jilles2014-03-271-1/+4
| | | | MFC after: 1 week
* sh: Fix possible memory leaks and double frees with unexpected SIGINT.jilles2014-03-265-14/+31
|
* sh: Don't overwrite old exit status if a PID is reused.jilles2014-03-201-1/+2
| | | | | | | | | Only store exit status for a process if that process has not terminated yet. Test (slow): exit 7 & p1=$!; until exit 8 & p2=$!; [ "$p1" = "$p2" ]; do wait "$p2"; done; sleep 0.1; wait %1; echo $? should write "7".
* sh: Allow kill %job on jobs started without job control.jilles2014-03-154-6/+24
| | | | | | | | When killing a %job started without job control, kill all processes in it. As with process groups and zombies, if any process in the job can be killed or has already terminated, the command is successful. This also fixes occasional failures of the builtins/kill1.0 test.
* sh: Add some consts.jilles2014-03-143-11/+11
|
* Make bsd.test.mk the only public mk fragment for the building of tests.jmmv2014-03-141-1/+1
| | | | | | | | | | | | | | Change {atf,plain,tap}.test.mk to be internal implementation details of bsd.test.mk. Makefiles that build tests should now only include bsd.test.mk and declaratively specify what they want to build, without worrying about the internal implementation of the mk files. The reason for this change is to permit building test programs of different interfaces from a single directory, which is something I had a need for while porting tests over from src/tools/regression/. Additionally, this change makes it possible to perform some other requested changes to bsd.test.mk in an easier manner. Coming soon.
* sh: Successfully do nothing when killing a terminated job.jilles2014-03-083-0/+11
| | | | | | If a job has terminated but is still known, silently do nothing when using the kill builtin with the job specifier. Formerly, the shell called kill() with the process group ID that might have been reused.
* sh: Make argstr() return where it stopped and simplify expari() using this.jilles2014-03-041-21/+5
|
* sh: Simplify expari().jilles2014-03-021-48/+46
| | | | | | | | | Redo expari() like evalvar(). This makes the logic more understandable and avoids possible problems if arithmetic expansion occurs if CTLESC characters are not generated (looking backwards for CTLARI is not generally possible in that case but the old code tried anyway). This adds an extra argstr() recursion.
* sh: Do not corrupt internal representation if LINENO inner expansion fails.jilles2014-02-273-6/+17
| | | | | | Example: f() { : ${LINENO+$((1/0))}; } and call this function twice.
* sh: Make expari() static.jilles2014-02-262-2/+2
|
* sh: Add -h option to SYNOPSISdaichi2014-02-251-3/+3
| | | | | Reviewed by: jilles MFC after: soon
* sh: Allow aliases to force alias substitution on the following word.jilles2014-01-268-3/+52
| | | | | | | | If an alias's value ends with a space or tab, the next word is also checked for aliases. This is a POSIX feature. It is useful with utilities like command and nohup (alias them to themselves followed by a space).
* sh: Add tests for alias names after another alias.jilles2014-01-253-0/+14
| | | | | Since the first alias's value does not end with a blank, the next word should not be checked for aliases.
* sh: Do not depend on parse/execute split in new alias test.jilles2014-01-241-1/+1
|
* sh: Solve the alias recursion problem in a less hackish way.jilles2014-01-245-48/+11
| | | | | | | | | Add the space to avoid alias recursion when the alias is expanded, not when it is added. As a result, displaying an alias via command -v, command -V or type no longer erroneously appends a space. Adjust the tests so they now require this bug to be absent.
* sh: Add test for nested alias.jilles2014-01-242-0/+7
|
* sh: Remove SIGWINCH handler and just check for resize before every read.jilles2014-01-143-23/+3
| | | | | | | | | | | | | The SIGWINCH handler triggers breakage in libedit which is hard to fix; see PR bin/169773. Also, window size changes while a program is in foreground (and it rather than sh will receive SIGWINCH) will now be picked up automatically. Downside: it is now certain that a resize is only processed after pressing <Enter>. If libedit is fixed, sh will most likely have to be changed also. PR: bin/180146
* Replace hand-crafted Kyuafiles with automatic generation.jmmv2014-01-142-13/+6
| | | | | | | | Redo r260506 by using the new TEST_METADATA functionality of bsd.test.mk to mark the sh(1) and test(1) tests as not supporting root. This is to get rid of hand-crafted Kyuafiles for these very simple cases. MFC after: 5 days
* Run the sh(1) and test(1) tests as unprivileged.jmmv2014-01-102-0/+13
| | | | | | | | | | | One of the tests for test(1) fails and some of the tests for sh(1) are silently bypassed when running as root. To fix these tests and ensure they all run, mark the test programs for sh(1) and test(1) as requiring an unprivileged user. (This should and will be the default in Kyua but isn't yet.) MFC after: 1 week
* sh(1): Discourage use of -e.jilles2014-01-031-2/+8
| | | | | Also, do not say that ! before a pipeline is an operator, because it is syntactically a keyword.
* sh: Don't check input for non-whitespace if history is disabled.jilles2013-12-271-8/+2
| | | | | | | | | | | preadbuffer() maintained a flag whether there was any non-whitespace character. This flag is only useful when history is enabled (in that case, lines containing only whitespace are not added to history). Instead, check using strspn() when history is enabled. There is an approximate 2% speedup when running sh -c '. /etc/rc.subr; . /etc/defaults/rc.conf; source_rc_confs' with hot cache.
* sh: Simplify code related to PPID variable.jilles2013-12-252-8/+2
|
* sh: Initialize OPTIND=1 even if it came from the environment.jilles2013-12-243-0/+5
|
* sh: Remove an unused variable.jilles2013-12-241-1/+0
|
OpenPOWER on IntegriCloud