259065 |
07-Dec-2013 |
gjb |
- Copy stable/10 (r259064) to releng/10.0 as part of the 10.0-RELEASE cycle. - Update __FreeBSD_version [1] - Set branch name to -RC1
[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so start releng/10.0 at '100' so the branch is started with a value ending in zero.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation |
256281 |
10-Oct-2013 |
gjb |
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
Approved by: re (implicit) Sponsored by: The FreeBSD Foundation
|
255215 |
04-Sep-2013 |
jilles |
sh: Make return return from the closest function or dot script.
Formerly, return always returned from a function if it was called from a function, even if there was a closer dot script. This was for compatibility with the Bourne shell which only allowed returning from functions.
Other modern shells and POSIX return from the function or the dot script, whichever is closest.
Git 1.8.4's rebase --continue depends on the POSIX behaviour.
Reported by: Christoph Mallon, avg
|
255157 |
02-Sep-2013 |
jilles |
sh: Fix race condition with signals and wait or set -T.
The change in r238888 was incomplete. It was still possible for a trapped signal to arrive before the shell went to sleep (sigsuspend()) because a check was missing or because the signal arrived before in_waitcmd was set.
On SMP, this bug sometimes caused the builtins/wait4.0 test to take 1 second to execute; it then might or might not fail. On UP, the test almost always failed.
|
255087 |
30-Aug-2013 |
jilles |
sh: Simplify list() in the parser.
The erflag argument was only used by old-style (``) command substitutions. We can remove it and handle the special case in the command substitution code.
|
255085 |
30-Aug-2013 |
jilles |
sh: Separate out nbinary allocation into a function.
|
255081 |
30-Aug-2013 |
jilles |
sh: Use makename() where possible.
|
255073 |
30-Aug-2013 |
jilles |
sh: Add a function for the case where one token is required in the parse.
|
255072 |
30-Aug-2013 |
jilles |
sh: Recognize "--" as end of options in type builtin.
This implementation makes minimal changes: command names starting with "-" (other than "--") can still be queried normally.
|
255068 |
30-Aug-2013 |
jilles |
sh: Cast -1 to pointer rather than pointer to variable of wrong type.
NEOF needs to be a non-null pointer distinct from valid union node pointers. It is not dereferenced.
The new NEOF is much like SIG_ERR except that it is an object pointer instead of a function pointer.
The variable tokpushback can now be static.
|
254849 |
25-Aug-2013 |
jilles |
sh: Recognize "--" as end of options in alias builtin.
Aliases starting with "-" (which are non-POSIX) will need to be preceded by an alias not starting with "-" or the newly added "--".
|
254843 |
25-Aug-2013 |
jilles |
sh: Disallow empty simple commands.
As per POSIX, a simple command must have at least one redirection, assignment word or command word.
These occured in rare cases such as eval "f()" .
The extension of allowing no commands inside { }, if, while, for, etc. remains.
|
254806 |
24-Aug-2013 |
jilles |
sh: Reject ++ and -- in arithmetic.
POSIX does not require ++ and -- in arithmetic. It is probably more useful to reject them than to treat ++x and --x as x silently.
Note that the behaviour of increment and decrement can be obtained via (x+=1), ((x+=1)-1), (x-=1) and ((x-=1)+1).
PR: bin/176444
|
254767 |
24-Aug-2013 |
jilles |
sh: Do not prematurely discard stopped jobs in a wait builtin.
If a job is specified to 'wait', wait for it to complete. Formerly, in interactive mode, the job was deleted if it stopped.
If no jobs are specified in interactive mode, 'wait' still waits for all jobs to complete or stop.
In non-interactive mode, WUNTRACED is not passed to wait3() so stopped jobs are not detected.
PR: bin/181435
|
254426 |
16-Aug-2013 |
jilles |
sh: Remove unnecessary reset functions.
These are already handled by exception handlers.
|
254413 |
16-Aug-2013 |
jilles |
sh: Recognize "--" as end of options in bg/fg/jobid builtins.
|
254339 |
14-Aug-2013 |
jilles |
sh: Recognize "--" as end of options in local builtin.
|
254335 |
14-Aug-2013 |
jilles |
sh: Allow a lone redirection before '|', ';;' or ';&'.
Example: </dev/null | :
PR: 181240 MFC after: 1 week
|
253659 |
25-Jul-2013 |
jilles |
sh: Remove an incorrect comment.
|
253658 |
25-Jul-2013 |
jilles |
sh: Remove #define MKINIT.
MKINIT only served for the removed mkinit. Many variables can be static now.
|
253650 |
25-Jul-2013 |
jilles |
sh: Remove mkinit.
Replace the RESET blocks with regular functions and a reset() function that calls them all.
This code generation tool is unusual and does not appear to provide much benefit. I do not think isolating the knowledge about which modules need to be reset is worth an almost 500-line build tool and wider scope for variables used by the reset functions.
Also, relying on reset functions is often wrong: the cleanup should be done in exception handlers so that no stale state remains after 'command eval' and the like.
|
253649 |
25-Jul-2013 |
jilles |
sh: Remove output.c's reset() handler.
These cleanup operations are not needed because they are already performed after an optimized command substitution (whether there was an error or not).
|
253271 |
12-Jul-2013 |
jilles |
sh: Do not read from stdin if an error occurs during -i -c cmd.
Although using -i with -c does not seem very useful, it seems inappropriate to read commands from the terminal in this case.
Side effect: if the -s -c extension is used and the -s option is turned off using 'set +s' during the interactive part, the shell now exits after an error or interrupt. Note that POSIX only specifies -s as option to sh, not to set.
See also Austin Group issue #718.
|
252359 |
28-Jun-2013 |
jilles |
sh: Do not close(-1) if pipe() fails.
|
251763 |
14-Jun-2013 |
jilles |
sh(1): A subshell environment has its own rlimits (ulimit).
This has always been the case and is intended (just like cd).
This matches Austin group issue #706.
|
251432 |
05-Jun-2013 |
jilles |
sh(1): Document new features in wait builtin.
PR: 176916
|
251430 |
05-Jun-2013 |
jilles |
sh: Return status 127 for unknown jobs in wait builtin.
This is required by POSIX, at least for pids that are not known child processes.
Other problems with job specifications still cause wait to abort with exit status 2.
PR: 176916
|
251429 |
05-Jun-2013 |
jilles |
sh: Allow multiple operands in wait builtin.
This is only part of the PR; the behaviour for unknown/invalid pids/jobs remains unchanged (aborts the builtin with status 2).
PR: 176916 Submitted by: Vadim Goncharov
|
250527 |
11-May-2013 |
jilles |
sh: Remove linked list of stack marks.
The linked list of stack marks may cause problems if the allocation stack is used between an exception and a higher-level popstackmark(), as it may then touch a stack mark that is local to a function which has returned.
Also, the adjustment compares to a pointer passed to realloc(), which is undefined behaviour.
Instead of adjusting stack marks when reallocating stack blocks, ensure that such an adjustment is never necessary by fixing a small piece of memory in place at a stack mark. This also simplifies the code.
To avoid the problems reported in bin/175922, it remains necessary to call setstackmark() after popstackmark() if the stack mark remains in use.
|
250422 |
09-May-2013 |
eadler |
Fix two typos
Reviewed by: jilles
|
250267 |
05-May-2013 |
jilles |
sh: Use O_CLOEXEC and F_DUPFD_CLOEXEC instead of separate fcntl() call.
|
250214 |
03-May-2013 |
jilles |
sh: Improve error handling in read builtin:
* If read -t times out, return status as if interrupted by SIGALRM (formerly 1). * If a trapped signal interrupts read, return status 128+sig (formerly 1). * If [EINTR] occurs but there is no trap, retry the read (for example because of a SIGWINCH in interactive mode). * If a read error occurs, write an error message and return status 2.
As before, a variable assignment error returns 2 and discards the remaining data read.
|
249984 |
27-Apr-2013 |
jilles |
sh: Don't consider jobs -s/-p as reporting the status of jobs.
This ensures that something like j=$(jobs -p) does not prevent any status from being written to the terminal.
|
249740 |
21-Apr-2013 |
joel |
Document a few expansions for the $PS1 and $PS2 environmental variables.
PR: 173410 Submitted by: Derek Wood <ddwood@outlook.com> Reviewed by: jilles
|
249407 |
12-Apr-2013 |
jilles |
sh: Don't modify exit status when break/continue/return passes !.
This matches what would happen if ! P were to be replaced with if P; then false; else true; fi.
Example: f() { ! return 0; }; f
|
249235 |
07-Apr-2013 |
jilles |
sh: Add const to nodesavestr().
|
249034 |
02-Apr-2013 |
jilles |
sh: Write as much into the heredoc pipe as possible, to avoid forking.
Use non-blocking I/O to write as much as the pipe will accept (often 64K, but it can be as little as 4K), avoiding the need for the ugly PIPESIZE constant. If PIPESIZE was set too high, a deadlock would occur.
|
248980 |
01-Apr-2013 |
jilles |
sh: Fix various compiler warnings.
It now passes WARNS=7 with clang on i386.
GCC 4.2.1 does not understand setjmp() properly so will always trigger -Wuninitialized. I will not add the volatile keywords to suppress this.
|
248870 |
29-Mar-2013 |
joel |
Minor mdoc fix.
|
248692 |
24-Mar-2013 |
jilles |
sh(1): Mention possible ambiguities with $(( and ((.
In some other shells, things like $((a);(b)) are command substitutions.
Also, there are shells that have an extension ((ARITH)) that evaluates an arithmetic expression and returns status 1 if the result is zero, 0 otherwise. This extension may lead to ambiguity with two subshells starting in sequence.
|
248349 |
15-Mar-2013 |
jilles |
sh: Recognize "--" and explicitly reject options in wait builtin.
If syntactically invalid job identifiers are to be taken as jobs that exited with status 127, this should not apply to options, so that we can add options later if need be.
|
247720 |
03-Mar-2013 |
jilles |
sh: When executing a trap, keep exit status along with evalskip.
This ensures 'return' in a trap returns the correct status to the caller.
If evalskip is not set or if it is overridden by a previous evalskip, keep the old behaviour of restoring the exit status from before the trap.
|
247206 |
23-Feb-2013 |
jilles |
sh: If a SIGINT or SIGQUIT interrupts "wait", return status 128+sig.
|
247013 |
19-Feb-2013 |
jilles |
sh: Fix a crash with the stackmark code.
If a stack mark is set while the current stack block is empty, the stack block may move later on (because of realloc()) and the stack mark needs to be updated. This updating does not happen after popstackmark() has been called; therefore, call setstackmark() again if the stack mark is still being used.
For some reason, this only affects a few users. I cannot reproduce it. The situation seems quite rare as well because an empty stack block would usually be freed (by popstackmark()) before execution reaches a setstackmark() call.
PR: 175922 Tested by: KT Sin
|
246522 |
07-Feb-2013 |
jilles |
sh: Simplify mksyntax and make it fit for cross-compiling.
Now it outputs fixed files, which use constants provided by the C standard library to determine appropriate values for the target machine.
Before, mksyntax inspected the host machine which resulted in subtle breakage if e.g. char is signed on the host and unsigned on the target such as when cross-compiling on x86 for ARM.
Tested using -funsigned-char on amd64. Compiling build-tools without it and sh itself with it causes various tests to fail without this change but not with this change. With consistent -funsigned-char, tests pass with or without this change.
The mksyntax program could be removed and syntax.c and syntax.h committed to the repository.
Submitted by: Christoph Mallon MFC after: 2 weeks
|
246507 |
07-Feb-2013 |
jilles |
sh: Fix a comment.
|
246495 |
07-Feb-2013 |
delphij |
Catch TRACE parameters up with r238888. This change is only needed when debugging is enabled.
|
246371 |
05-Feb-2013 |
jilles |
sh: Do not test for digit_contig in mksyntax.
ISO/IEC 9899:1999 (E) 5.2.1p3 guarantees that the values of the characters 0123456789 are contiguous.
The generated syntax.c and syntax.h remain the same.
Submitted by: Christoph Mallon
|
246288 |
03-Feb-2013 |
jilles |
sh: Expand here documents in the current process.
Expand here documents at the same point other redirections are expanded but use a non-fork subshell environment (like simple command substitutions) for compatibility. Substitition errors result in an empty here document like before.
As a result, a fork is avoided for short (<4K) expanded here documents.
Unexpanded here documents (with quoted end marker after <<) are not affected by this change. They already only forked when >4K.
Side effects: * Order of expansion is slightly different. * Slow expansions are not executed in parallel with the redirected command. * A non-fork subshell environment is subtly different from a forked process.
|
246167 |
31-Jan-2013 |
jilles |
sh: Prefer our character classification functions to <ctype.h>.
|
246162 |
31-Jan-2013 |
jilles |
sh: Show negated commands (!) in jobs output.
|
245805 |
22-Jan-2013 |
joel |
Add FILES section.
Discussed with: jilles
|
245699 |
20-Jan-2013 |
joel |
Change the $ENV example to use .shrc instead of .shinit. This is consistent with what we use in /usr/share/skel/dot.profile.
Discussed with: jilles
|
245698 |
20-Jan-2013 |
jilles |
sh: Move some stackmarks to fix high memory usage in some loops.
If a loop contained certain commands (such as redirected compound commands), the temporary memory for the redirection was not freed between iterations of the loop but only after the loop.
Put a stackmark in evaltree(), freeing memory whenever a node has been evaluated. Some other stackmarks are then redundant; remove them.
Example: while :; do { :; } </dev/null; done
|
245689 |
20-Jan-2013 |
jilles |
sh: Remove mkinit's initialization routine.
Instead, call the only init function left directly from main().
|
245676 |
19-Jan-2013 |
jilles |
sh: Replace an mkinit use with an initialization.
|
245426 |
14-Jan-2013 |
jilles |
sh: Simplify cd-hash interaction.
Instead of rechecking relative paths for all hashed utilities after a cd, track if any utility in cmdtable depends on a relative path in PATH. If there is such a utility, cd clears the entire table.
As a result, the '*' in hash no longer happens.
|
245422 |
14-Jan-2013 |
jilles |
sh: Pass $? to command substitution containing compound/multiple commands.
Example: false; echo $(echo $?; :)
|
245382 |
13-Jan-2013 |
jilles |
sh: Fix crash when parsing '{ } &'.
MFC after: 1 week
|
245381 |
13-Jan-2013 |
jilles |
sh: Don't lose $? when backquoted command ends with semicolon or newline.
An empty simple command was added and overwrote the exit status with 0.
This affects `...` but not $(...).
Example: v=`false;`; echo $?
|
244682 |
25-Dec-2012 |
jilles |
sh: Prefer strsignal() to accessing sys_siglist directly.
Accessing sys_siglist directly requires rtld to copy it from libc to the sh executable's BSS. Also, strsignal() will put in the signal number for unknown signals (FreeBSD-specific) so we need not do that ourselves.
Unfortunately, there is no function for sys_signame.
|
244162 |
12-Dec-2012 |
jilles |
sh: Detect and flag write errors on stdout in builtins.
If there is a write error on stdout, a message will be printed (to stderr) and the exit status will be changed to 2 if it would have been 0 or 1.
PR: bin/158206
|
243027 |
14-Nov-2012 |
jilles |
sh: Remove an unused variable.
|
242895 |
11-Nov-2012 |
jilles |
sh: Forward-declare struct alias instead of giving up type safety via void *
|
242766 |
08-Nov-2012 |
jilles |
sh: Fix two issues when an alias is redefined:
* The last character is not displayed. * If the alias ends with itself (as a word), an infinite memory-eating loop occurs.
If an alias is defined initially, a space is appended to avoid recursion but this did not happen when an alias was later modified.
PR: bin/173418 Submitted by: Daniel F. MFC after: 1 week
|
242620 |
05-Nov-2012 |
jilles |
sh: Change cmdtype in tblentry from short to signed char.
If this is a smaller type than int anyway, we can make it the smallest possible.
|
242530 |
03-Nov-2012 |
jilles |
sh: Use C99 flexible array instead of accessing array beyond bounds.
Although sufficient memory is available for a longer string in cmdname, this is undefined behaviour anyway.
Side effect: for alignment reasons, an additional byte of memory is allocated per hashed command.
|
241544 |
14-Oct-2012 |
joel |
mdoc: don't nest displays. The markup here isn't adding anything anyway. Fixes a mandoc lint warning.
Discussed with: brueffer, Jason McIntyre <jmc@kerhand.co.uk>
|
240541 |
15-Sep-2012 |
jilles |
sh: Prefer internal nextopt() to libc getopt().
This reduces code duplication and code size.
/usr/bin/printf is not affected.
Side effect: different error messages when certain builtins are passed invalid options.
|
240505 |
14-Sep-2012 |
jilles |
sh: Reduce code duplication: use setinputfile instead of open/setinputfd combination.
MFC after: 2 weeks
|
240369 |
11-Sep-2012 |
joel |
Minor mdoc fix.
|
240247 |
08-Sep-2012 |
jilles |
sh: Remove XXX comment about removing nextopt().
Using nextopt() avoids depending on the BSD-specific optreset feature in getopt() and reduces code size (both source and binary).
|
238888 |
29-Jul-2012 |
jilles |
sh: Fix EINTR race condition in "wait" and "set -T" using sigsuspend().
When waiting for child processes using "wait" or if "set -T" is in effect, a signal interrupts the wait. Make sure there is no window where the signal handler may be invoked (setting a flag) just before going to sleep.
There is a similar race condition in the shell language, but scripts can avoid it by exiting from the trap handler or enforcing synchronization using a fifo.
If SIGCHLD is not trapped, a signal handler must be installed for it. Only install this handler for the duration of the wait to avoid triggering unexpected [EINTR] errors elsewhere.
Note that for some reason only SIGINT and SIGQUIT interrupt a "wait" command. This remains the case.
|
238867 |
28-Jul-2012 |
jilles |
sh: Do not ask for stopped/continued processes if we do not need them rather than retrying wait3 if they happen.
|
238866 |
28-Jul-2012 |
jilles |
sh: Inline waitproc() into its only caller.
|
238865 |
28-Jul-2012 |
jilles |
sh: Track continued jobs (even if not continued by bg or fg).
This uses wait3's WCONTINUED flag.
There is no message for this. The change is visible in "jobs" or if the job stops again.
|
238477 |
15-Jul-2012 |
jilles |
sh: Reset pendingsigs before checking pending traps, not after.
Otherwise, a signal arriving at exactly the right moment might not be processed until another signal arrived.
|
238470 |
15-Jul-2012 |
jilles |
sh: Remove unused variable in_dowait.
|
238468 |
15-Jul-2012 |
jilles |
sh: Expand assignment-like words specially for export/readonly/local.
Examples: export x=~ now expands the tilde local y=$1 is now safe, even if $1 contains IFS characters or metacharacters.
For a word to "look like an assignment", it must start with a name followed by an equals sign, none of which may be quoted.
The special treatment applies when the first word (potentially after "command") is "export", "readonly" or "local". There may be quoting characters but no expansions. If "local" is overridden with a function there is no special treatment ("export" and "readonly" cannot be overridden with a function).
If things like local arr=(1 2 3) are ever allowed in the future, they cannot call a "local" function. This would either be a run-time error or it would call the builtin.
This matches Austin Group bug #351, planned for the next issue of POSIX.1.
PR: bin/166771
|
238377 |
11-Jul-2012 |
pfg |
Merge libedit adjustment from NetBSD.
On recent versions of NetBSD's libedit, el_gets now sets el_len to -1 on error so we can distinguish between a NULL string and an error.
This fixes sh from exiting with newer versions of libedit now allowing EINTR to return.
Obtained from: NetBSD Reviewed by: jilles MFC after: 3 weeks
|
235927 |
24-May-2012 |
marcel |
Work better with how make/bmake works: 1. Avoid a cd back into ${.CURDIR} to run mkbuiltins when we know make will first cd into ${.OBJDIR}. Keep the cwd to what make sets it to. 2. Don't tell mkbuiltins where to write to (= ${.OBJDIR}), but where to get sources from (= ${.CURDIR}). This to compensate for point 1.
This fixes a problem with bmake's mk files that optimize ${.OBJDIR} to expand to "." after changing cwd, not taking into account that the target is pretty much undoing that and not getting the full path to the object tree anymore.
|
235488 |
15-May-2012 |
jilles |
sh: Remove an unused header.
The read builtin no longer does things with termios.
|
235400 |
13-May-2012 |
joel |
Minor mdoc nits.
|
233992 |
07-Apr-2012 |
joel |
mdoc: fix column names, indentation, column separation within each row, and quotation. Also make sure we have the same amount of columns in each row as the number of columns we specify in the head arguments.
Reviewed by: brueffer
|
233792 |
02-Apr-2012 |
jilles |
sh: Fix build with -DDEBUG=2.
Reported by: Kristof Provost MFC after: 1 week
|
233648 |
29-Mar-2012 |
eadler |
Remove trailing whitespace per mdoc lint warning
Disussed with: gavin No objection from: doc Approved by: joel MFC after: 3 days
|
233457 |
25-Mar-2012 |
joel |
Remove superfluous paragraph macro.
|
231535 |
11-Feb-2012 |
jilles |
sh: Make 'hash' return 1 if at least one utility is not found.
Reported by: lme
|
231001 |
04-Feb-2012 |
jilles |
sh: Fix swapped INTON/INTOFF.
A possible consequence of this bug was a memory leak if SIGINT arrived during a 'set' command (listing variables).
MFC after: 1 week
|
230998 |
04-Feb-2012 |
jilles |
sh: Use vfork in a few common cases.
This uses vfork() for simple commands and command substitutions containing a single simple command, invoking an external program under certain conditions (no redirections or variable assignments, non-interactive shell, no job control). These restrictions limit the amount of code executed in a vforked child.
There is a large speedup (for example 35%) in microbenchmarks. The difference in buildkernel is smaller (for example 0.5%) but still statistically significant. See http://lists.freebsd.org/pipermail/freebsd-hackers/2012-January/037581.html for some numbers.
The use of vfork() can be disabled by setting a variable named SH_DISABLE_VFORK.
|
230530 |
25-Jan-2012 |
charnier |
Add prototypes, ANSIfy functions definitions to reduce WARNS=6 output.
|
230463 |
22-Jan-2012 |
jilles |
sh: Fix $? in the first command of a 'for'.
In the first command of a 'for', $? should be the exit status of the last pipeline (command substitution in the word list or command before 'for'), not always 0.
|
230437 |
21-Jan-2012 |
jilles |
sh: Remove "kill" example function, which is superseded by the kill builtin
MFC after: 1 week
|
230212 |
16-Jan-2012 |
dumbbell |
sh: Fix execution of multiple statements in a trap when evalskip is set
Before this fix, only the first statement of the trap was executed if evalskip was set. This is for example the case when: o "-e" is set for this shell o a trap is set on EXIT o a function returns 1 and causes the script to abort
Reviewed by: jilles MFC after: 2 weeks
|
230161 |
15-Jan-2012 |
jilles |
sh: Fix some bugs with exit status from case containing ;&.
Also, rework evalcase() to not evaluate any tree. Instead, return the NCLISTFALLTHRU node and handle it in evaltree().
Fixed bugs:
* If a ;& list with non-zero exit status is followed by an empty ;; or final list, the exit status of the case command should be equal to the exit status of the ;& list, not 0.
* An empty ;& case should not reset $?.
|
230154 |
15-Jan-2012 |
jilles |
sh: Fix two bugs with case and exit status:
* If no pattern is matched, POSIX says the exit status shall be 0 (even if there are command substitutions). * If a pattern is matched and there are no command substitutions, the first command should see the $? from before the case command, not always 0.
|
230118 |
14-Jan-2012 |
jilles |
sh: Change input buffer size from 1023 to 1024.
PR: bin/161756
|
230117 |
14-Jan-2012 |
jilles |
sh: Fix out of bounds array access when trap is used with an invalid signal.
MFC after: 1 week
|
230095 |
13-Jan-2012 |
jilles |
sh: Properly show "Not a directory" error in cd builtin.
The errno message display added in r222292 did not take attempting to cd to a non-directory or something that cannot be stat()ed into account.
PR: bin/164070 MFC after: 10 days
|
229220 |
01-Jan-2012 |
jilles |
sh: Make various functions static.
|
229219 |
01-Jan-2012 |
jilles |
sh: Remove unused function scopyn().
|
229201 |
01-Jan-2012 |
jilles |
sh: Make patmatch() non-recursive.
|
228943 |
28-Dec-2011 |
jilles |
sh: Allow quoting ^ and ] in bracket expressions.
|
228942 |
28-Dec-2011 |
jilles |
sh: Use dirent.d_type in pathname generation.
This improves performance for globs where a slash or another component follows a component with metacharacters by eliminating unnecessary attempts to open directories that are not.
|
228941 |
28-Dec-2011 |
jilles |
sh: Cache de->d_namlen in a local variable.
|
228937 |
28-Dec-2011 |
jilles |
sh: Do not force special builtins non-special in optimized command subst.
This is not necessary: errors are already caught in evalbackcmd() and forcelocal handles changes to variables.
Note that this depends on r223024.
MFC after: 4 weeks
|
228015 |
27-Nov-2011 |
jilles |
sh: Remove impossible evalskip check in 'for'.
|
228013 |
26-Nov-2011 |
jilles |
sh: Reduce one level of evaltree() recursion when executing 'case'. Free expanded case text before executing commands. Remove impossible evalskip checks (expanding an argument cannot set evalskip anymore since $(break) and the like are properly executed in a subshell environment).
|
227773 |
20-Nov-2011 |
jilles |
sh: Allow unsetting OPTIND.
Note that only assigning the decimal value 1 resets getopts, as before.
|
227369 |
08-Nov-2011 |
jilles |
sh: Remove undefined behaviour due to overflow in +/-/* in arithmetic.
With i386 base gcc and i386 base clang, arith_yacc.o remains unchanged.
|
227122 |
05-Nov-2011 |
jilles |
sh(1): Improve documentation of field splitting.
|
223909 |
10-Jul-2011 |
jilles |
sh(1): Extend documentation about subshells.
Because sh executes commands in subshell environments without forking in more and more cases (particularly from 8.0 on), it makes sense to describe subshell environments more precisely using ideas from POSIX, together with some FreeBSD-specific items.
In particular, the hash and times builtins may not behave as if their state is copied for a subshell environment while leaving the parent shell environment unchanged.
|
223580 |
26-Jun-2011 |
jilles |
sh: Include <limits.h> instead of non-standard <sys/limits.h>.
|
223522 |
24-Jun-2011 |
jilles |
sh(1): Improve documentation of shell patterns:
* Shell patterns are also for ${var#pat} and the like. * An '!' by itself will not trigger pathname generation so do not call it a meta-character, even though it has a special meaning directly after an '['. * Character ranges are locale-dependent. * A '^' will complement a character class like '!' but is non-standard.
MFC after: 1 week
|
223517 |
24-Jun-2011 |
jilles |
sh(1): Document the case command better.
Suggested by: netchild Reviewed by: gjb
|
223494 |
24-Jun-2011 |
kevlo |
Remove duplicated header files
|
223282 |
19-Jun-2011 |
jilles |
sh: Remove special support for background simple commands.
It expands the arguments in the parent shell process, which is incorrect.
|
223281 |
18-Jun-2011 |
jilles |
sh: Add do-nothing -h option.
POSIX requires a -h option to sh and set, to locate and remember utilities invoked by functions as they are defined. Given that this locate-and-remember process is optional elsewhere, it seems safe enough to make this option do nothing.
POSIX does not specify a long name for this option. Follow ksh in calling it "trackall".
|
223186 |
17-Jun-2011 |
jilles |
sh: Add case statement fallthrough (with ';&' instead of ';;').
Replacing ;; with the new control operator ;& will cause the next list to be executed as well without checking its pattern, continuing until a list ends with ;; or until the end of the case statement. This is like omitting "break" in a C "switch" statement.
The sequence ;& was formerly invalid.
This feature is proposed for the next POSIX issue in Austin Group issue #449.
|
223183 |
17-Jun-2011 |
jilles |
sh: Skip variables with invalid names in "set", "export -p", "readonly -p".
This ensures the output of these commands is valid shell input.
|
223163 |
16-Jun-2011 |
jilles |
sh: Reduce unnecessary forks with eval.
The eval special builtin now runs the code with EV_EXIT if it was run with EV_EXIT itself.
In particular, this eliminates one fork when a command substitution contains an eval command that ends with an external program or a subshell.
This is similar to what r220978 did for functions.
|
223120 |
15-Jun-2011 |
jilles |
sh: Add support for named character classes in bracket expressions.
Example: case x in [[:alpha:]]) echo yes ;; esac
|
223060 |
13-Jun-2011 |
jilles |
sh: Fix duplicate prototypes for builtins.
Have mkbuiltins write the prototypes for the *cmd functions to builtins.h instead of builtins.c and include builtins.h in more .c files instead of duplicating prototypes for *cmd functions in other headers.
|
223024 |
12-Jun-2011 |
jilles |
sh: Save/restore changed variables in optimized command substitution.
In optimized command substitution, save and restore any variables changed by expansions (${var=value} and $((var=assigned))), instead of trying to determine if an expansion may cause such changes.
If $! is referenced in optimized command substitution, do not cause jobs to be remembered longer.
This fixes $(jobs $!) again, simplifies the man page and shortens the code.
|
223010 |
12-Jun-2011 |
jilles |
sh: Fix locale-dependent ranges in bracket expressions.
When I added UTF-8 support in r221646, the LC_COLLATE-based ordering broke because of sign extension of char.
Because of libc restrictions, this does not work for UTF-8. For UTF-8 locales, ranges always use character code order.
|
223005 |
12-Jun-2011 |
jilles |
sh: Read .profile from the home directory (or / if HOME is not set).
In most cases, login shells are started from the home directory, but not in all, such as xterm -ls.
This commit depends on r222957 for read_profile() performing parameter expansion.
PR: bin/50569
|
222957 |
10-Jun-2011 |
jilles |
sh: Do parameter expansion on ENV before using it.
This is required by POSIX, and allows things like ENV=\$HOME/.shrc.
Note that tilde expansion is explicitly not performed.
|
222907 |
09-Jun-2011 |
jilles |
sh: Do parameter expansion before printing PS4 (set -x).
The function name expandstr() and the general idea of doing this kind of expansion by treating the text as a here document without end marker is from dash.
All variants of parameter expansion and arithmetic expansion also work (the latter is not required by POSIX but it does not take extra code and many other shells also allow it).
Command substitution is prevented because I think it causes too much code to be re-entered (for example creating an unbounded recursion of trace lines).
Unfortunately, our LINENO is somewhat crude, otherwise PS4='$LINENO+ ' would be quite useful.
|
222716 |
05-Jun-2011 |
jilles |
sh: Fix $? in heredocs on simple commands.
PR: bin/41410
|
222699 |
04-Jun-2011 |
jilles |
sh: Improve error message if the script cannot be opened.
Avoid "<nosuchfile>: cannot open <nosuchfile>: ...".
|
222684 |
04-Jun-2011 |
jilles |
sh: Reduce more needless differences between error messages.
|
222676 |
04-Jun-2011 |
jilles |
sh: Honour -n while processing -c string.
|
222386 |
27-May-2011 |
jilles |
sh: Remove the "exp" builtin.
The "exp" builtin is undocumented, non-standard and not very useful.
If exp's return value is not used, something like VAR=$(exp EXPRESSION) is equivalent to VAR=$((EXPRESSION)) except that errors in the expression are fatal and quoting special characters is not needed in the latter case.
If exp's return value is used, something like if exp EXPRESSION >/dev/null can be replaced by if [ $((EXPRESSION)) -ne 0 ] with similar differences.
The exp-run showed that "let" is close enough to bash's and ksh's builtin that removing it would break a few ports. Therefore, "let" remains in 9.x.
PR: bin/104432 Exp-run done by: pav (with some other sh(1) changes)
|
222381 |
27-May-2011 |
jilles |
sh: Correct criterion for using CDPATH in cd.
CDPATH should be ignored not only for pathnames starting with '/' but also for pathnames whose first component is '.' or '..'.
The man page already describes this behaviour.
|
222362 |
27-May-2011 |
jilles |
sh: Various updates to the TOUR document.
|
222361 |
27-May-2011 |
jilles |
sh: Fix unquoted $@/$* if IFS=''.
If IFS is null, unquoted $@/$* should still expand to separate words. This differs from quoted $@ (which does not depend on IFS) in that pathname generation is performed and empty words are removed.
|
222292 |
25-May-2011 |
jilles |
sh: Show errno messages in cd.
|
222182 |
22-May-2011 |
jilles |
sh: Remove obsolete token type TENDBQUOTE.
This token type was related to Almquist's original version of backquotes that could not nest and fell into disuse fairly soon.
|
222178 |
22-May-2011 |
uqs |
Fix some typos under bin/
Found by: codespell
|
222173 |
22-May-2011 |
jilles |
sh: Fix bss-based buffer overflow in . builtin.
If the length of a directory in PATH together with the given filename exceeded FILENAME_MAX (which may happen even for pathnames that work), a static buffer was overflown.
The static buffer is unnecessary, we can use the stalloc() stack.
Obtained from: NetBSD MFC after: 1 week
|
222165 |
21-May-2011 |
jilles |
sh: Expand aliases after assignments and redirections.
|
222154 |
20-May-2011 |
jilles |
sh: Implement the cd -e flag proposed for the next POSIX issue.
This reflects failure to determine the pathname of the new directory in the exit status (1). Normally, cd returns successfully if it did chdir() and the call was successful.
In POSIX, -e only has meaning with -P; because our -L is not entirely compliant and may fall back to -P mode, -e has some effect with -L as well.
|
222134 |
20-May-2011 |
jilles |
sh: Allow terminating a heredoc with a terminator at EOF without a newline.
This is sometimes used with eval or old-style command substitution, and most shells other than ash derivatives allow it.
It can also be used with scripts that violate POSIX's requirement on the application that they end in a newline (scripts must be text files except that line length is unlimited).
Example: v=`cat <<EOF foo EOF` echo $v
This commit does not add support for the similar construct with new-style command substitution, like v=$(cat <<EOF foo EOF) This continues to require a newline after the terminator.
|
221975 |
15-May-2011 |
jilles |
sh: Minor optimization to output from ulimit/export/readonly.
No functional change is intended.
|
221970 |
15-May-2011 |
jilles |
sh: Avoid close(-1) when evaluating a multi-command pipeline.
Valgrind complains about this.
|
221669 |
08-May-2011 |
jilles |
sh: Add \u/\U support (in $'...') for UTF-8.
Because we have no iconv in base, support for other charsets is not possible.
Note that \u/\U are processed using the locale that was active when the shell started. This is necessary to avoid behaviour that depends on the parse/execute split (for example when placing braces around an entire script). Therefore, UTF-8 encoding is implemented manually.
|
221668 |
08-May-2011 |
jilles |
sh: Optimize variable code by storing the length of the name.
Obtained from: NetBSD
|
221660 |
08-May-2011 |
jilles |
sh(1): Update BUGS section for UTF-8 support.
|
221646 |
08-May-2011 |
jilles |
sh: Add UTF-8 support to pattern matching.
?, [...] patterns match codepoints instead of bytes. They do not match invalid sequences. [...] patterns must not contain invalid sequences otherwise they will not match anything. This is so that ${var#?} removes the first codepoint, not the first byte, without putting UTF-8 knowledge into the ${var#pattern} code. However, * continues to match any string and an invalid sequence matches an identical invalid sequence. (This differs from fnmatch(3).)
|
221602 |
07-May-2011 |
jilles |
sh: Add UTF-8 support to ${#var}.
If the current locale uses UTF-8, ${#var} counts codepoints (more precisely, bytes b with (b & 0xc0) != 0x80).
|
221559 |
06-May-2011 |
jilles |
sh: Track if the current locale's charset is UTF-8 or not.
|
221551 |
06-May-2011 |
jilles |
sh: Change the CTL* bytes to ones invalid in UTF-8.
This ensures that mbrtowc(3) can be used directly once it has been verified that there is no CTL* byte. Dealing with a CTLESC byte within a multibyte character would be complicated.
The new values do occur in iso-8859-* encodings. This decreases efficiency slightly but should not affect correctness.
Caveat: Updating across this change and rebuilding without cleaning may yield a subtly broken sh binary. By default, make buildworld will clean and avoid problems.
|
221513 |
05-May-2011 |
jilles |
sh: Add $'quoting' (C-style escape sequences).
A string between $' and ' may contain backslash escape sequences similar to the ones in a C string constant (except that a single-quote must be escaped and a double-quote need not be). Details are in the sh(1) man page.
This construct is useful to include unprintable characters, tabs and newlines in strings; while this can be done with a command substitution containing a printf command, that needs ugly workarounds if the result is to end with a newline as command substitution removes all trailing newlines.
The construct may also be useful in future to describe unprintable characters without needing to write those characters themselves in 'set -x', 'export -p' and the like.
The implementation attempts to comply to the proposal for the next issue of the POSIX specification. Because this construct is not in POSIX.1-2008, using it in scripts intended to be portable is unwise.
Matching the minimal locale support in the rest of sh, the \u and \U sequences are currently not useful.
Exp-run done by: pav (with some other sh(1) changes)
|
221463 |
04-May-2011 |
jilles |
sh: Apply set -u to variables in arithmetic.
Note that this only applies to variables that are actually used. Things like (0 && unsetvar) do not cause an error.
Exp-run done by: pav (with some other sh(1) changes)
|
221461 |
04-May-2011 |
jilles |
sh: Detect an error for ${#var<GARBAGE>}.
In particular, this makes things like ${#foo[0]} and ${#foo[@]} errors rather than silent equivalents of ${#foo}.
PR: bin/151720 Submitted by: Mark Johnston Exp-run done by: pav (with some other sh(1) changes)
|
221027 |
25-Apr-2011 |
jilles |
sh: Set $? to 0 for background commands.
For backgrounded pipelines and subshells, the previous value of $? was being preserved, which is incorrect.
For backgrounded simple commands containing a command substitution, the status of the last command substitution was returned instead of 0.
If fork() fails, this is an error.
|
221012 |
25-Apr-2011 |
jilles |
sh: Check setuid()/setgid() return values.
If the -p option is turned off, privileges from a setuid or setgid binary are dropped. Make sure to check if this succeeds. If it fails, this is an error which will cause the shell to abort except in interactive mode or if 'command' was used to make 'set' or an outer 'eval' or '.' non-special.
Note that taking advantage of this feature and writing setuid shell scripts seems unwise.
MFC after: 1 week
|
221011 |
25-Apr-2011 |
jilles |
sh: Remove duplicate code resetting uid/gid for set +p/+o privileged.
MFC after: 1 week
|
220978 |
23-Apr-2011 |
jilles |
sh: Allow EV_EXIT through function calls, make {...} <redir more consistent.
If EV_EXIT causes an exit, use the exception mechanism to unwind redirections and local variables. This way, if the final command is a redirected command, an EXIT trap now executes without the redirections.
Because of these changes, EV_EXIT can now be inherited by the body of a function, so do so. This means that a function no longer prevents a fork before an exec being skipped, such as in f() { head -1 /etc/passwd; }; echo $(f)
Wrapping a single builtin in a function may still cause an otherwise unnecessary fork with command substitution, however.
An exit command or -e failure still invokes the EXIT trap with the original redirections and local variables in place.
Note: this depends on SHELLPROC being gone. A SHELLPROC depended on keeping the redirections and local variables and only cleaning up the state to restore them.
|
220903 |
20-Apr-2011 |
jilles |
sh: Do not word split "${#parameter}".
This is only a problem if IFS contains digits, which is unusual but valid.
Because of an incorrect fix for PR bin/12137, "${#parameter}" was treated as ${#parameter}. The underlying problem was that "${#parameter}" erroneously added CTLESC bytes before determining the length. This was properly fixed for PR bin/56147 but the incorrect fix was not backed out.
Reported by: Seeker on forums.freebsd.org MFC after: 2 weeks
|
219806 |
20-Mar-2011 |
jilles |
sh(1): Describe subshell environment, command substitution more correctly.
POSIX does not require the shell to fork for a subshell environment, and we use that possibility in various ways (command substitutions with a single command and most subshells that are the final command of a shell process). Therefore do not tie subshells to forking in the man page.
Command substitutions with expansions are a bit strange, causing a fork for $(...$(($x))...) because $x might expand to y=2; they will probably be changed later but this is how they work now.
|
219623 |
13-Mar-2011 |
jilles |
sh: Fix some parameter expansion variants ${#...}.
These already worked: $# ${#} ${##} ${#-} ${#?} These now work as well: ${#+word} ${#-word} ${##word} ${#%word}
There is an ambiguity in the standard with ${#?}: it could be the length of $? or it could be $# giving an error in the (impossible) case that it is not set. We continue to use the former interpretation as it seems more useful.
|
219363 |
07-Mar-2011 |
stefanf |
Remove unnecessary cast.
Reviewed by: jilles
|
219350 |
06-Mar-2011 |
jilles |
sh(1): Reduce excessive semicolon-separated sentences.
Reported by: Benjamin Kaduk
|
219306 |
05-Mar-2011 |
jilles |
sh: Fix some warnings in code for arithmetic expressions.
Submitted by: eadler
|
218909 |
21-Feb-2011 |
brucec |
Fix typos - remove duplicate "the".
PR: bin/154928 Submitted by: Eitan Adler <lists at eitanadler.com> MFC after: 3 days
|
218626 |
12-Feb-2011 |
jilles |
sh: Detect dividing the smallest integer by -1.
This overflows and on some architectures such as amd64 it generates SIGFPE. Generate an error on all architectures.
|
218467 |
08-Feb-2011 |
jilles |
sh(1): Update description of arithmetic.
|
218466 |
08-Feb-2011 |
jilles |
sh: Import arithmetic expression code from dash.
New features: * proper lazy evaluation of || and && * ?: ternary operator * executable is considerably smaller (8K on i386) because lex and yacc are no longer used
Differences from dash: * arith_t instead of intmax_t * imaxdiv() not used * unset or null variables default to 0 * let/exp builtin (undocumented, will probably be removed later)
Obtained from: dash
|
218325 |
05-Feb-2011 |
jilles |
sh: Fix two things about {(...)} <redir:
* In {(...) <redir1;} <redir2, do not drop redir1. * Maintain the difference between (...) <redir and {(...)} <redir: In (...) <redir, the redirection is performed in the child, while in {(...)} <redir it should be performed in the parent (like {(...); :;} <redir)
|
218324 |
05-Feb-2011 |
jilles |
sh: Remove clearcmdentry()'s now unused argument.
|
218323 |
05-Feb-2011 |
jilles |
sh: Forget all cached command locations on any PATH change.
POSIX requires this and it is simpler than the previous code that remembered command locations when appending directories to PATH.
In particular, PATH=$PATH is no longer a no-op but discards all cached command locations.
|
218320 |
05-Feb-2011 |
jilles |
sh: Do not try to execute binary files as scripts.
If execve() returns an [ENOEXEC] error, check if the file is binary before trying to execute it using sh. A file is considered binary if at least one of the first 256 bytes is '\0'.
In particular, trying to execute ELF binaries for the wrong architecture now fails with an "Exec format error" message instead of syntax errors and potentially strange results.
|
218306 |
04-Feb-2011 |
jilles |
sh: Remove special code for shell scripts without magic number.
These are called "shell procedures" in the source.
If execve() failed with [ENOEXEC], the shell would reinitialize itself and execute the program as a script. This requires a fair amount of code which is not frequently used (most scripts have a #! magic number). Therefore just execute a new instance of sh (_PATH_BSHELL) to run the script.
|
218285 |
04-Feb-2011 |
jilles |
Make sys_signame upper case.
This matches the constants from <signal.h> with 'SIG' removed, which POSIX requires kill and trap to accept and 'kill -l' to write.
'kill -l', 'trap', 'trap -l' output is now upper case.
In Turkish locales, signal names with an upper case 'I' are now accepted, while signal names with a lower case 'i' are no longer accepted, and the output of 'killall -l' now contains proper capital 'I' without dot instead of a dotted capital 'I'.
|
218242 |
03-Feb-2011 |
jilles |
sh: Return only 126 or 127 for execve() failures.
Do not return 2 for errors other than [EACCES] or [ENOENT].
|
218203 |
02-Feb-2011 |
jilles |
sh: Remove comment mentioning herefd, which is gone.
|
218105 |
30-Jan-2011 |
jilles |
sh: Send messages about signals to stderr.
This is required by POSIX and seems to make more sense.
See also r217557.
|
217847 |
25-Jan-2011 |
jilles |
sh: Clean up some old comments: * There is no plan for an alternative to the command "set". * Attempting to unset a readonly variable has not raised an error for quite a while, so the order of unsetting a variable and a function with the same name does not matter.
MFC after: 1 week
|
217557 |
18-Jan-2011 |
jilles |
sh: Fix signal messages being sent to the wrong file sometimes.
When a foreground job exits on a signal, a message is printed to stdout about this. The buffer was not flushed after this which could result in the message being written to the wrong file if the next command was a builtin and had stdout redirected.
Example: sh -c 'kill -9 $$'; : > foo; echo FOO:; cat foo
Reported by: gcooper MFC after: 1 week
|
217473 |
16-Jan-2011 |
jilles |
sh(1): Document changes to 'exit' from traps.
|
217472 |
16-Jan-2011 |
jilles |
sh: If exit is used without args from a trap action, exit on the signal.
This is useful so that it is easier to exit on a signal than to reset the trap to default and resend the signal. It matches ksh93. POSIX says that 'exit' without args from a trap action uses the exit status from the last command before the trap, which is different from 'exit $?' and matches this if the previous command is assumed to have exited on the signal.
If the signal is SIGSTOP, SIGTSTP, SIGTTIN or SIGTTOU, or if the default action for the signal is to ignore it, a normal _exit(2) is done with exit status 128+signal_number.
|
217461 |
15-Jan-2011 |
jilles |
sh: Fix some things about -- in trap: * Make 'trap --' do the same as 'trap' instead of nothing. * Make '--' stop option processing (note that '-' action is not an option).
Side effect: The error message for an unknown option is different.
|
217425 |
14-Jan-2011 |
jilles |
sh: Make 'trap -l' look like 'kill -l'.
|
217209 |
09-Jan-2011 |
jilles |
sh: Follow-up to r216743, grabstackblock() can be replaced with stalloc().
grabstackblock() was used only once (but it is a very often executed piece of code).
|
217206 |
09-Jan-2011 |
jilles |
sh: Remove special %builtin PATH entry. All builtins are now always found before a PATH search.
Most ash derivatives have an undocumented feature where the presence of an entry "%builtin" in $PATH will cause builtins to be checked at that point of the PATH search, rather than before looking at any directories as documented in the man page (very old versions do document this feature).
I am removing this feature from sh, as it complicates the code, may violate expectations (for example, /usr/bin/alias is very close to a forkbomb with PATH=/usr/bin:%builtin, only /usr/bin/builtin not being another link saves it) and appears to be unused (all the %builtin google code search finds is in some sort of ash source code).
Note that aliases and functions took and take precedence above builtins. Because aliases work on a lexical level they can only ever be overridden on a lexical level (quoting or preceding 'builtin' or 'command'). Allowing override of functions via PATH does not really fit in the model of sh and it would work differently from %builtin if implemented.
Note: POSIX says special builtins are found before functions. We comply to this because we do not allow functions with the same name as a special builtin.
Silence from: freebsd-hackers@ (message sent 20101225) Discussed with: dougb
|
217175 |
08-Jan-2011 |
jilles |
sh: Make exit without parameters from EXIT trap POSIX-compliant.
It should use the original exit status, just like falling off the end of the trap handler.
Outside an EXIT trap, 'exit' is still equivalent to 'exit $?'.
|
217035 |
05-Jan-2011 |
jilles |
sh: Do not call exitshell() from evalcommand() unless evalcommand() forked itself.
This ensures that certain traps caused by builtins are executed.
|
216870 |
01-Jan-2011 |
jilles |
sh: Check readonly status for assignments on regular builtins.
An error message is written, the builtin is not executed, nonzero exit status is returned but the shell does not abort.
This was already checked for special builtins and external commands, with the same consequences except that the shell aborts for special builtins.
Obtained from: NetBSD
|
216851 |
31-Dec-2010 |
jilles |
sh: Check if dup2 for redirection from/to a file succeeds.
A failure (e.g. caused by ulimit -n being set very low) is a redirection error.
Example: ulimit -n 9; exec 9<.
|
216826 |
30-Dec-2010 |
jilles |
sh: Avoid side effects from builtins in optimized command substitution.
Change the criterion for builtins to be safe to execute in the same process in optimized command substitution from a blacklist of only cd, . and eval to a whitelist.
This avoids clobbering the main shell environment such as by $(exit 4) and $(set -x).
The builtins jobid, jobs, times and trap can still show information not available in a child process; this is deliberately permitted. (Changing traps is not.)
For some builtins, whether they are safe depends on the arguments passed to them. Some of these are always considered unsafe to keep things simple; this only harms efficiency a little in the rare case they are used alone in a command substitution.
|
216806 |
29-Dec-2010 |
jilles |
sh: Properly restore exception handler in fc.
If SIGINT arrived at exactly the right moment (unlikely), an exception handler in a no longer active stack frame would be called.
Because the old handler was not used in the normal path, clang thought it was a dead value and if an exception happened it would longjmp() to garbage. This caused builtins/fc1.0 to fail if histedit.c was compiled with clang.
MFC after: 1 week
|
216778 |
28-Dec-2010 |
jilles |
sh: Don't do optimized command substitution if expansions have side effects.
Before considering to execute a command substitution in the same process, check if any of the expansions may have a side effect; if so, execute it in a new process just like happens if it is not a single simple command.
Although the check happens at run time, it is a static check that does not depend on current state. It is triggered by: - expanding $! (which may cause the job to be remembered) - ${var=value} default value assignment - assignment operators in arithmetic - parameter substitutions in arithmetic except ${#param}, $$, $# and $? - command substitutions in arithmetic
This means that $((v+1)) does not prevent optimized command substitution, whereas $(($v+1)) does, because $v might expand to something containing assignment operators.
Scripts should not depend on these exact details for correctness. It is also imaginable to have the shell fork if and when a side effect is encountered or to create a new temporary namespace for variables.
Due to the $! change, the construct $(jobs $!) no longer works. The value of $! should be stored in a variable outside command substitution first.
|
216761 |
28-Dec-2010 |
jilles |
sh: Make expansion errors in optimized command substitution non-fatal. Command substitutions consisting of a single simple command are executed in the main shell process but this should be invisible apart from performance and very few exceptions such as $(trap).
|
216743 |
27-Dec-2010 |
jilles |
sh: Simplify "stack string" code slightly.
Maintain a pointer to the end of the stack string area instead of how much space is left. This simplifies the macros in memalloc.h. The places where the new variable must be updated are only where the memory area is created, destroyed or resized.
|
216707 |
26-Dec-2010 |
jilles |
sh: Fix integer overflow check, it checked an uninitialized variable.
|
216706 |
26-Dec-2010 |
jilles |
sh: Allow arbitrary large numbers in CHECKSTRSPACE. Reduce "stack string" API somewhat and simplify code. Add a check for integer overflow of the "stack string" length (probably incomplete).
|
216630 |
21-Dec-2010 |
jilles |
sh(1): Explain why it is a bad idea to use aliases in scripts.
|
216629 |
21-Dec-2010 |
jilles |
sh: Add kill builtin.
This allows specifying a %job (which is equivalent to the corresponding process group).
Additionally, it improves reliability of kill from sh in high-load situations and ensures "kill" finds the correct utility regardless of PATH, as required by POSIX (unless the undocumented %builtin mechanism is used).
Side effect: fatal errors (any error other than kill(2) failure) now return exit status 2 instead of 1. (This is consistent with other sh builtins, but not in NetBSD.)
Code size increases about 1K on i386.
Obtained from: NetBSD
|
216622 |
21-Dec-2010 |
jilles |
sh: Add a function to print warnings (with command name and newline). This is like error() but without raising an exception. It is particularly useful as a replacement for the warnx macro in bltin/bltin.h.
|
216606 |
20-Dec-2010 |
jilles |
sh: Make warnings in the printf builtin non-fatal, like in the program.
The #define for warnx now behaves much like the libc function (except that it uses sh command name and output).
Also, it now uses C99 __VA_ARGS__ so there is no need for three different macros for 0, 1 or 2 parameters.
|
216547 |
18-Dec-2010 |
jilles |
sh: arith: Disallow decimal constants starting with 0 (containing 8 or 9).
Constants in arithmetic starting with 0 should be octal only.
This avoids the following highly puzzling result: $ echo $((018-017)) 3 by making it an error instead.
|
216544 |
18-Dec-2010 |
uqs |
Remove dead code.
c is assigned 0 and *loc is pointing to NULL, so c!=0 cannot be true, and dereferencing loc would be a bad idea anyway.
Coverity Prevent: CID 5113 Reviewed by: jilles
|
216496 |
16-Dec-2010 |
jilles |
sh: Fix corruption of command substitutions with special chars after newline
The CTLESC byte to protect a special character was output before instead of after a newline directly preceding the special character.
The special handling of newlines is because command substitutions discard all trailing newlines.
|
216404 |
13-Dec-2010 |
uqs |
Remove duplicate check, turning dead code into live code.
Coverity CID: 5114 Reviewed by: jilles
|
216400 |
12-Dec-2010 |
jilles |
sh: Various simplifications to jobs.c: * Prefer kill(-X) to killpg(X). * Remove some dead code. * No additional SIGINT is needed if int_pending() is already true.
No functional change is intended.
|
216387 |
12-Dec-2010 |
jilles |
sh: Remove the herefd hack.
The herefd hack wrote out partial here documents while expanding them. It seems unnecessary complication given that other expansions just allocate memory. It causes bugs because the stack is also used for intermediate results such as arithmetic expressions. Such places should disable herefd for the duration but not all of them do, and I prefer removing the need for disabling herefd to disabling it everywhere needed.
Here documents larger than 1024 bytes will use a bit more CPU time and memory.
Additionally this allows a later change to expand here documents in the current shell environment. (This is faster for small here documents but also changes behaviour.)
Obtained from: dash
|
216384 |
11-Dec-2010 |
jilles |
sh: Replace some macros and repeated code in expand.c with functions.
No functional change is intended, but the binary is about 1K smaller on i386.
|
216380 |
11-Dec-2010 |
jilles |
sh: Use vsnprintf() rather than crafting our own in fmtstr(). Add INTOFF/INTON as longjmp out of vsnprintf may cause memory leaks or undefined behaviour.
|
216246 |
07-Dec-2010 |
jilles |
sh: Improve internal-representation-to-text code to avoid binary output.
The code to translate the internal representation to text did not know about various additions to the internal representation since the original ash and therefore wrote binary stuff to the terminal.
The code is used in the jobs command and similar output.
Note that the output is far from complete and mostly serves for recognition purposes.
|
216220 |
05-Dec-2010 |
jilles |
sh: POSIX says there should not be a space between Done and (exitstatus).
(On the other hand, (core dumped) does need a space and so does [1] +.)
|
216217 |
05-Dec-2010 |
jilles |
sh: Improve jobs output of pipelines.
If describing the status of a pipeline, write all elements of the pipeline and show the status of the last process (which would also end up in $?). Only write one report per job, not one for every process that exits.
To keep some earlier behaviour, if any process started by the shell in a foreground job terminates because of a signal, write a message about the signal (at most one message per job, however).
Also, do not write messages about signals in the wait builtin in non-interactive shells. Only true foreground jobs now write such messages (for example, "Terminated").
|
216208 |
05-Dec-2010 |
jilles |
sh: Avoid marking a job as done before it is fully created.
In r208489, I added code to reap zombies when forking new processes, to limit the amount of zombies. However, this can lead to marking a job as done or stopped if it consists of multiple processes and the first process ends very quickly. Fix this by only checking for zombies before forking the first process of a job and not marking any jobs without processes as done or stopped.
|
216199 |
05-Dec-2010 |
jilles |
sh: jobs -p: Do not ask the kernel for the pgid.
The getpgid() call will fail if the first process in the job has already terminated, resulting in output of "-1".
The pgid of a job is always the pid of the first process in the job and other code already relies on this.
|
216168 |
03-Dec-2010 |
jilles |
sh(1): Clean up documentation of built-in commands.
Make sure all built-in commands are in the subsection named such, except exp, let and wordexp which are deliberately undocumented. The text said only built-ins that really need to be a built-in were documented there but in fact almost all of them were already documented.
|
216100 |
01-Dec-2010 |
jilles |
sh(1): Document that command's -p option also works with -v/-V.
This was implemented in r201343.
|
215783 |
23-Nov-2010 |
jilles |
sh: Code size optimizations to "stack string" memory allocation: * Prefer one CHECKSTRSPACE with multiple USTPUTC to multiple STPUTC. * Add STPUTS macro (based on function) and use it instead of loops that add nul-terminated strings to the stack string.
No functional change is intended, but code size is about 1K less on i386.
|
215766 |
23-Nov-2010 |
jilles |
sh: Pass multiple bytes at a time to lex.
This speeds up the expansion/arith6.0 test considerably.
|
215727 |
22-Nov-2010 |
jilles |
sh: Fix confusing behaviour if chdir succeeded but getcwd failed in cd -P.
If getcwd fails, do not treat this as an error, but print a warning and unset PWD. This is similar to the behaviour when starting the shell in a directory whose name cannot be determined.
|
215704 |
22-Nov-2010 |
brucec |
Fix some more warnings found by clang.
|
215568 |
20-Nov-2010 |
jilles |
sh: Remove the check that alpha/name/in_name chars are not CTL* bytes.
Since is_alpha/is_name/is_in_name were made ASCII-only, this can no longer happen.
Additionally, the check was wrong because it did not include the new CTLQUOTEEND.
|
215567 |
20-Nov-2010 |
jilles |
sh: Code size optimizations to buffered output.
This is mainly less use of the outc macro.
No functional change is intended, but code size is about 2K less on i386.
|
215520 |
19-Nov-2010 |
jilles |
sh: Add printf builtin.
This was removed in 2001 but I think it is appropriate to add it back: * I do not want to encourage people to write fragile and non-portable echo commands by making printf much slower than echo. * Recent versions of Autoconf use it a lot. * Almost no software still wants to support systems that do not have printf(1) at all. * In many other shells printf is already a builtin.
Side effect: printf is now always the builtin version (which behaves identically to /usr/bin/printf) and cannot be overridden via PATH (except via the undocumented %builtin mechanism).
Code size increases about 5K on i386. Embedded folks might want to replace /usr/bin/printf with a hard link to /usr/bin/alias.
|
215303 |
14-Nov-2010 |
jilles |
sh: Add binary buffered output for use by the printf builtin.
|
215268 |
13-Nov-2010 |
jilles |
sh: Update the suspend example for the change of the job control flag from -j to -m, many years ago.
Due to r215266, this function now actually works.
|
215266 |
13-Nov-2010 |
jilles |
sh: Do the additional actions if 'local -' restore changes -i/-m/-E/-V.
Example: f() { local -; set +m; }; f caused failure to execute external programs because the job control tty fd was not opened.
|
215210 |
12-Nov-2010 |
jilles |
sh(1): Document r214304 (special builtin is illegal function name).
|
215209 |
12-Nov-2010 |
jilles |
sh(1): Update for r214492. "${v+"hi}there"}".
The part hi}there is not a quoted string but nevertheless the closing brace does not terminate the expansion.
|
215184 |
12-Nov-2010 |
jilles |
sh: Remove unused man page for echo builtin.
The information in sh(1) about the echo builtin is equivalent, though less extensive.
The echo(1) man page (bin/echo/echo.1) is different.
Unfortunately, sh's echo builtin and /bin/echo have gone out of sync and this probably cannot be fixed any more.
Reported by: uqs (list of untouched files) MFC after: 1 week
|
215181 |
12-Nov-2010 |
jilles |
sh(1): Modernize the introduction a bit.
In particular, remove the text about ksh-like features, which are usually taken for granted nowadays. The original Bourne shell is fading away and for most users our /bin/sh is one of the most minimalistic they know.
|
214709 |
02-Nov-2010 |
jilles |
sh: Fix some issues with aliases and case, by importing dash checkkwd code.
This moves the function of the noaliases variable into the checkkwd variable. This way it is properly reset on errors and aliases can be used normally in the commands for each case (the case labels recognize the keyword esac but no aliases).
The new code is clearer as well.
Obtained from: dash
|
214609 |
31-Oct-2010 |
jilles |
sh(1): Correct synopsis and make precise how $0 is set.
In particular, the extra argument to set $0 with -c was not documented.
MFC after: 1 week
|
214600 |
31-Oct-2010 |
jilles |
sh: Reindent evaltree().
|
214599 |
31-Oct-2010 |
jilles |
sh: Use iteration instead of recursion to evaluate semicolon lists. This reduces CPU and memory usage when executing long lists (such as long functions).
|
214538 |
29-Oct-2010 |
jilles |
sh: Tweak some string constants to reduce code size.
* Reduce some needless differences. * Shorten some error messages that should not happen.
|
214534 |
29-Oct-2010 |
jilles |
sh: Reject function names ending in one of !%*+-=?@}~
These do something else in ksh: name=(...) is an array or compound variable assignment and the others are extended patterns.
This is the last patch of the ones tested in the exp run.
Exp-run done by: pav (with some other sh(1) changes)
|
214531 |
29-Oct-2010 |
jilles |
sh: Detect various additional errors in the parser.
Apart from detecting breakage earlier or at all, this also fixes a segfault in the testsuite. The "handling" of the breakage left an invalid internal representation in some cases.
Examples: echo a; do echo b echo `) echo a` echo `date; do do do`
Exp-run done by: pav (with some other sh(1) changes)
|
214525 |
29-Oct-2010 |
jilles |
sh: Error out on various specials/keywords in the wrong place in backticks.
Example: echo `date)`
Exp-run done by: pav (with some other sh(1) changes) Obtained from: NetBSD (Christos Zoulas, NetBSD PR 11317)
|
214524 |
29-Oct-2010 |
jilles |
sh: Fix some issues with CTL* bytes and ${var#pat}.
subevalvar() incorrectly assumed that CTLESC bytes were present iff the expansion was quoted. However, they are present iff various processing such as word splitting is to be done later on.
Example: v=@$e@$e@$e@ y="${v##*"$e"}" echo "$y" failed if $e contained the magic CTLESC byte.
Exp-run done by: pav (with some other sh(1) changes)
|
214512 |
29-Oct-2010 |
jilles |
sh: Do IFS splitting on word in ${v+word} and ${v-word}.
The code is inspired by NetBSD sh somewhat, but different because we preserve the old Almquist/Bourne/Korn ability to have an unquoted part in a quoted ${v+word}. For example, "${v-"*"}" expands to $v as a single field if v is set, but generates filenames otherwise.
Note that this is the only place where we split text literally from the script (the similar ${v=word} assigns to v and then expands $v). The parser must now add additional markers to allow the expansion code to know whether arbitrary characters in substitutions are quoted.
Example: for i in ${$+a b c}; do echo $i; done
Exp-run done by: pav (with some other sh(1) changes)
|
214492 |
28-Oct-2010 |
jilles |
sh: Only accept a '}' inside ${v+-=?...} if double-quote state matches. If double-quote state does not match, treat the '}' literally.
This ensures double-quote state remains the same before and after a ${v+-=?...} which helps with expand.c.
It makes things like ${foo+"\${bar}"} which I have seen in the wild work as expected.
Exp-run done by: pav (with some other sh(1) changes)
|
214490 |
28-Oct-2010 |
jilles |
sh: Make double-quotes quote a '}' inside ${v#...} and ${v%...}.
Exp-run done by: pav (with some other sh(1) changes) PR: bin/57554
|
214305 |
24-Oct-2010 |
jilles |
sh: Ignore double-quotes in arithmetic rather than treating them as quotes.
This provides similar behaviour, but allows a simpler parser.
This changes r206473.
Exp-run done by: pav (with some other sh(1) changes)
|
214304 |
24-Oct-2010 |
jilles |
sh: Do not allow overriding a special builtin with a function. This is a syntax error.
POSIX does not say explicitly whether defining a function with the same name as a special builtin is allowed, but it does say that it is impossible to call such a function.
A special builtin can still be overridden with an alias.
This commit is part of a set of changes that will ensure that when something looks like a special builtin to the parser, it is one. (Not the other way around, as it remains possible to call a special builtin named by a variable or other substitution.)
Exp-run done by: pav (with some other sh(1) changes)
|
214291 |
24-Oct-2010 |
jilles |
sh: Make sure defined functions can actually be called.
Add some conservative checks on function names: - Disallow expansions or quoting characters; these can only be called via strange control characters - Disallow '/'; these functions cannot be called anyway, as exec.c assumes they are pathnames - Make the CTL* bytes work properly in function names.
These are syntax errors.
POSIX does not require us to support more than names (letters, digits and underscores, not starting with a digit), but I do not want to restrict it that much at this time.
Exp-run done by: pav (with some other sh(1) changes)
|
214290 |
24-Oct-2010 |
jilles |
sh: Check whether dup2 was successful for >&FD and <&FD.
A failure (usually caused by FD not being open) is a redirection error.
Exp-run done by: pav (with some other sh(1) changes)
|
214281 |
24-Oct-2010 |
jilles |
sh: Change ! within a pipeline to start a new pipeline instead.
This is how ksh93 treats ! within a pipeline and makes the ! in a | ! b | c negate the exit status of the pipeline, as if it were a | { ! b | c; }
Side effect: something like f() ! a is now a syntax error, because a function definition takes a command, not a pipeline.
Exp-run done by: pav (with some other sh(1) changes)
|
213926 |
16-Oct-2010 |
jilles |
sh(1): Clarify subshells/processes for pipelines.
For multi-command pipelines, 1. all commands are direct children of the shell (unlike the original Bourne shell) 2. all commands are executed in a subshell (unlike the real Korn shell)
MFC after: 1 week
|
213925 |
16-Oct-2010 |
jilles |
sh: Use <stddef.h> rather than <sys/stddef.h>.
<sys/stddef.h> is only for the kernel and conflicts with <stddef.h>.
|
213815 |
13-Oct-2010 |
obrien |
We only need to look as far as '..' to find 'test/'.
|
213814 |
13-Oct-2010 |
obrien |
Do not assume in growstackstr() that a "precious" character will be immediately written into the stack after the call. Instead let the caller manage the "space left".
Previously, growstackstr()'s assumption causes problems with STACKSTRNUL() where we want to be able to turn a stack into a C string, and later pretend the NUL is not there.
This fixes a bug in STACKSTRNUL() (that grew the stack) where: 1. STADJUST() called after a STACKSTRNUL() results in an improper adjust. This can be seen in ${var%pattern} and ${var%%pattern} evaluation. 2. Memory leak in STPUTC() called after a STACKSTRNUL().
Reviewed by: jilles
|
213811 |
13-Oct-2010 |
obrien |
In the spirit of r90111, depend on c89 and remove the "STATIC" macro and its usage.
|
213798 |
13-Oct-2010 |
obrien |
If one wishes to set breakpoints of static the functions here, they cannot be inlined.
Submitted by: jhb
|
213775 |
13-Oct-2010 |
jhb |
Make DEBUG traces 64-bit clean: - Use %t to print ptrdiff_t values. - Cast a ptrdiff_t value explicitly to int for a field width specifier.
While here, sort includes.
Submitted by: Garrett Cooper
|
213774 |
13-Oct-2010 |
jhb |
Suggest that DEBUG_FLAGS be used to enable extra debugging rather than frobbing CFLAGS directly. DEBUG_FLAGS is something that can be specified on the make command line without having to edit the Makefile directly.
Submitted by: Garrett Cooper
|
213760 |
13-Oct-2010 |
obrien |
Consistently use "STATIC" for all functions in order to be able to set breakpoints with in a debugger. And use naked "static" for variables.
Noticed by: bde
|
213744 |
12-Oct-2010 |
obrien |
If DEBUG is 3 or greater, disable STATICization of functions. Also correct the documented location of the trace file.
|
213738 |
12-Oct-2010 |
obrien |
Allow one to regression test 'sh' changes without having to install a potentially bad /bin/sh first.
|
212508 |
12-Sep-2010 |
jilles |
sh: Add __dead2 to two functions that do not return.
Apart from helping static analyzers, this also appears to reduce the size of the binary slightly.
|
212475 |
11-Sep-2010 |
jilles |
sh: Fix exit status if return is used within a loop condition.
|
212467 |
11-Sep-2010 |
jilles |
sh: Apply variable assignments left-to-right in bltinlookup().
Example: HOME=foo HOME=bar cd
|
212417 |
10-Sep-2010 |
jilles |
sh(1): Remove xrefs for expr(1) and getopt(1).
expr(1) should usually not be used as various forms of parameter expansion and arithmetic expansion replicate most of its functionality in an easier way.
getopt(1) should not be used at all in new code. Instead, getopts(1) or entirely manual parsing should be used.
MFC after: 1 week
|
212339 |
08-Sep-2010 |
jilles |
sh: Fix 'read' if all chars before the first IFS char are backslash-escaped.
Backslash-escaped characters did not set the flag for a non-IFS character.
MFC after: 2 weeks
|
212243 |
05-Sep-2010 |
jilles |
sh: Improve comments in expand.c.
|
212214 |
04-Sep-2010 |
jilles |
sh: Get rid of some magic numbers.
MFC after: 1 week
|
212190 |
03-Sep-2010 |
jilles |
sh: Do not use locale for determining if something is a name.
This makes it impossible to use locale-specific characters in variable names.
Names containing locale-specific characters make scripts only work with the correct locale setting. Also, they did not even work in many practical cases because multibyte character sets such as utf-8 are not supported.
This also avoids weirdness if LC_CTYPE is changed in the middle of a script.
|
211646 |
22-Aug-2010 |
jilles |
sh: Remove remnants of '!!' to negate pattern.
This Almquist extension was disabled long ago.
In pathname generation, components starting with '!!' were treated as containing wildcards, causing unnecessary readdir (which could fail, causing pathname generation to fail while it should not).
|
211621 |
22-Aug-2010 |
jilles |
sh(1): Add a brief summary of arithmetic expressions.
|
211349 |
15-Aug-2010 |
jilles |
sh: Fix break/continue/return sometimes not skipping the rest of dot script.
In our implementation and most others, a break or continue in a dot script can break or continue a loop outside the dot script. This should cause all further commands in the dot script to be skipped. However, cmdloop() did not know about this and continued to parse and execute commands from the dot script.
As described in the man page, a return in a dot script in a function returns from the function, not only from the dot script. There was a similar issue as with break and continue. In various other shells, the return appears to return from the dot script, but POSIX seems not very clear about this.
|
211287 |
13-Aug-2010 |
jilles |
sh: Add a forgotten const.
|
211281 |
13-Aug-2010 |
jilles |
sh: Fix shadowing of sigset.
|
211155 |
10-Aug-2010 |
jilles |
sh: Fix heap-based buffer overflow in pathname generation.
The buffer for generated pathnames could be too small in some cases. It happened to be always at least PATH_MAX long, so there was never an overflow if the resulting pathnames would be usable.
This bug may be abused if a script subjects input from an untrusted source to pathname generation, which a bad idea anyhow. Most shell scripts do not work on untrusted data. secteam@ says no advisory is necessary.
PR: bin/148733 Reported by: Changming Sun snnn119 at gmail com MFC after: 10 days
|
211084 |
08-Aug-2010 |
jilles |
Remove unnecessary duplicate letters in mksyntax.c, the table elements would just be overwritten twice.
|
210829 |
03-Aug-2010 |
jilles |
sh: Return 0 from eval if no command was given.
This makes a difference if there is a command substitution.
To make this work, evalstring() has been changed to set exitstatus to 0 if no command was executed (the string contained only whitespace).
Example: eval $(false); echo $? should print 0.
|
210736 |
01-Aug-2010 |
jilles |
sh: Do not enter consecutive duplicates into the history.
This simply sets a flag in libedit. It has a shortcoming in that it does not apply to multi-line commands.
Note that a configuration option for this is not going to happen, but always having this seems better than not having it. NetBSD has done the same.
PR: bin/54683 Obtained from: NetBSD MFC after: 1 month
|
210488 |
25-Jul-2010 |
jilles |
sh: Fix crash due to uninitialized here-document.
If an ; or & token was followed by an EOF token, pending here-documents were left uninitialized. Execution would crash, either in the main shell process for literal here-documents or in a child process for expanded here-documents. In the latter case the problem is hard to detect apart from the core dumps and log messages.
Side effect: slightly different retries on inputs where EOF is not persistent.
Note that tools/regression/bin/sh/parser/heredoc6.0 still causes a similar crash in a child process. The text passed to eval is malformed and should be rejected.
|
210221 |
18-Jul-2010 |
jilles |
sh: Allow a background command consisting solely of redirections.
Example: </dev/null &
MFC after: 2 weeks
|
210087 |
14-Jul-2010 |
jilles |
sh: There cannot be a TNOT in simplecmd(), remove checks.
simplecmd() only handles simple commands and function definitions, neither of which involves the ! keyword. The initial token on entry to simplecmd() is one of the following: TSEMI, TAND, TOR, TNL, TEOF, TWORD, TRP.
|
209653 |
02-Jul-2010 |
jilles |
sh: Use $PWD instead of getcwd() for the \w and \W prompt expansions.
This ensures that the logical working directory (which may include symlinks) is shown and is similar to the default behaviour of the pwd builtin.
|
209600 |
29-Jun-2010 |
jilles |
sh: Forget about terminated background processes sooner.
Unless $! has been referenced for a particular job or $! still contains that job's pid, forget about it after it has terminated. If $! has been referenced, remember the job until the wait builtin has reported its completion (either with the pid as parameter or without parameters).
In interactive mode, jobs are forgotten after termination has been reported, which happens before primary prompts and through the jobs builtin. Even then, though, remember a job if $! has been referenced.
This is similar to what is suggested by POSIX and should fix most memory leaks (which also tend to cause sh to use more CPU time) with long running scripts that start background jobs.
Caveats: * Repeatedly referencing $! without ever doing 'wait', like while :; do foo & echo started foo: $!; sleep 60; done will still use a lot of memory and CPU time in the long run. * The jobs and jobid builtins do not cause a job to be remembered for longer like expanding $! does.
PR: bin/55346
|
209337 |
19-Jun-2010 |
jilles |
sh: Fix compilation with -DNO_HISTORY.
The LINENO code uses snprintf() and relied on "myhistedit.h" to pull in the necessary <stdio.h>.
Compiling with -DNO_HISTORY disables all editing and history support and allows linking without -ledit -ltermcap. This may be useful for embedded systems.
MFC after: 2 weeks
|
209221 |
15-Jun-2010 |
jilles |
sh: Add filename completion.
This uses the new libedit completion function with quoting support.
Unlike NetBSD, there is no 'set +o tabcomplete' option to disable completion. I do not see any reason for such a special treatment, as completion is rather useful and it is possible to do bind ^I ed-insert to disable completion and insert a tab character instead.
Submitted by: Guy Yur
|
208881 |
06-Jun-2010 |
jilles |
sh: Pass through SIGINT from a child if interactive and job control is enabled.
This already worked if without job control.
In either case, this depends on it that a process that terminates due to SIGINT exits on it (so not with status 1, or worse, 0).
Example: sleep 5; echo continued This does not print "continued" any more if sleep is aborted via ctrl+c.
MFC after: 1 month
|
208755 |
02-Jun-2010 |
jilles |
sh: Pass TERM changes to libedit.
I have changed the patch slightly to ignore TERM changes in subshells.
PR: bin/146916 Submitted by: Guy Yur Obtained from: NetBSD
|
208656 |
30-May-2010 |
jilles |
sh: Fix a crash if a heredoc was not properly ended and parsing continued.
Example (in interactive mode): cat <<EOF && ) The next command typed caused sh to segfault, because the state for the here document was not reset.
Like parser_temp, this uses the fact that the parser is not re-entered.
|
208655 |
30-May-2010 |
jilles |
sh: Change interaction of command substitution and here documents.
If a command substitution contains a newline token, this no longer starts here documents of outer commands. This way, we follow POSIX's idea of the command substitution being a separate script more closely. It also matches other shells better and is consistent with newline characters in quotes not starting here documents.
The extension tested in parser/heredoc3.0 ($(cat <<EOF)\ntext\nEOF\n) continues to be supported.
In particular, this change allows things like cat <<EOF && echo `pwd` (a `` command substitution after a here document) which formerly silently used an empty file as the here document, because the EOF of the inner command "pwd" also forced an empty here document.
|
208630 |
28-May-2010 |
jilles |
sh: Recognize "--" in . and exec.
Although "--" historically has not been required to be recognized for certain special builtins that do not take options in POSIX, some other implementations recognize options for them, requiring scripts to use "--" or avoid operands starting with "-".
Operands starting with "-" can be avoided with eval by prepending a space, and cannot occur with break, continue, exit, return and shift as they only take numbers, nor with times as it does not take operands. With . and exec, avoiding "-" is not so easy as it may require reimplementing the PATH search; therefore the current proposal for POSIX is to require recognition of "--" for them.
We continue to accept other strings starting with "-" as operands to . and exec, and also "--" if it is alone to . (which would otherwise be invalid anyway).
|
208505 |
24-May-2010 |
jilles |
sh(1): Rework documentation of shell variables.
* Move the "environment variables" that do not need exporting to be effective or that are set by the shell without exporting to a new section "Special Variables". * Add special variables LINENO and PPID. * Add environment variables LANG, LC_* and PWD; also describe ENV under environment variables.
|
208501 |
24-May-2010 |
jilles |
sh(1): Improve wording of 'Special Parameters' section.
|
208489 |
24-May-2010 |
jilles |
sh: Reap any zombies before forking for a background command.
This prevents accumulating huge amounts of zombies if a script executes many background commands but no external commands or subshells.
Note that zombies will not be reaped during long calculations (within the shell process) or read builtins, but those actions do not create more zombies.
The terminated background commands will also still be remembered by the shell.
PR: bin/55346
|
207944 |
11-May-2010 |
jilles |
sh: Fix pathname expansion with quoted slashes like *\/.
These are git commits 36f0fa8fcbc8c7b2b194addd29100fb40e73e4e9 and d6d06ff5c2ea0fa44becc5ef4340e5f2f15073e4 in dash.
Because this is the first code I'm importing from dash to expand.c, add the Herbert Xu copyright notice which is in dash's expand.c.
When pathname expanding *\/, the CTLESC representing the quoted state was erroneously taken as part of the * pathname component. This CTLESC was then seen by the pattern matching code as escaping the '\0' terminating the string.
The code is slightly different because dash converts the CTLESC characters to backslashes and removes all the other CTL* characters to allow substituting glob(3).
The effect of the bug was also slightly different from dash (where nothing matched at all). Because a CTLESC can escape a '\0' in some way, whether files were included despite the bug depended on memory that should not be read. In particular, on many machines /*\/ expanded to a strict subset of what /*/ expanded to.
Example: echo /*"/null"
This should print /dev/null, not /*/null.
PR: bin/146378 Obtained from: dash
|
207831 |
09-May-2010 |
jilles |
sh(1): Fix "reserved word" vs "keyword" inconsistency. Use "keyword" everywhere, like the output of the 'type' builtin, and only mention "reserved word" once to say it is the same thing.
|
207783 |
08-May-2010 |
jilles |
sh: Have only one copy of _PATH_STDPATH in the binary.
|
207678 |
05-May-2010 |
jilles |
sh: Apply locale vars on builtins, recognize LC_MESSAGES as a locale var.
This allows doing things like LC_ALL=C some_builtin to run a builtin under a different locale, just like is possible with external programs. The immediate reason is that this allows making printf(1) a builtin without breaking things like LC_NUMERIC=C printf '%f\n' 1.2
This change also affects special builtins, as even though the assignment is persistent, the export is only to the builtin (unless the variable was already exported).
Note: for this to work for builtins that also exist as external programs such as /bin/test, the setlocale() call must be under #ifndef SHELL. The shell will do the setlocale() calls which may not agree with the environment variables.
|
207206 |
25-Apr-2010 |
jilles |
sh: Use stalloc for arith variable names.
This is simpler than the custom memory tracker I added earlier, and is also needed by the dash arith code I plan to import.
|
206759 |
17-Apr-2010 |
jilles |
sh: On startup of the shell, use PWD from the environment if it is valid. Unset PWD if it is incorrect and no value for it can be determined. This preserves the logical current directory across shell invocations.
Example (assuming /home is a symlink): $ cd $ pwd /home/foo $ sh $ pwd /home/foo
Formerly the second pwd would show the physical path (symlinks resolved).
|
206473 |
11-Apr-2010 |
jilles |
sh: Partially revert r206146, allowing double-quotes in arithmetic.
These do pretty much nothing (except that parentheses are ignored), but people seem to use them and allowing them does not hurt much.
Single-quotes seem not to be used and cause silently different behaviour with ksh93 character constants.
|
206182 |
05-Apr-2010 |
jilles |
sh: Automatically enable -o emacs in interactive shells with terminals.
This makes sh a bit more friendly in single user mode, make buildenv, chroot and the like, and matches other shells.
The -o emacs can be overridden on the command line or in the ENV file.
|
206158 |
04-Apr-2010 |
jilles |
sh: Document the expansion changes in the man page.
Note that the following sentence > Enclosing the full parameter expansion string in double-quotes does not > cause the following four varieties of pattern characters to be quoted, > whereas quoting characters within the braces has this effect. is now true, but used to be incorrect.
|
206150 |
03-Apr-2010 |
jilles |
sh: Do tilde expansion in substitutions.
This applies to word in ${v-word}, ${v+word}, ${v=word}, ${v?word} (which inherits quoting from the outside) and in ${v%word}, ${v%%word}, ${v#word}, ${v##word} (which does not inherit any quoting).
In all cases tilde expansion is only attempted at the start of word, even if word contains spaces. This agrees with POSIX and other shells.
This is the last part of the patch tested in the exp-run.
Exp-run done by: erwin (with some other sh(1) changes)
|
206147 |
03-Apr-2010 |
jilles |
sh: Allow quoting pattern match characters in ${v%pat} and ${v#pat}.
Note that this depends on r206145 for allowing pattern match characters to have their special meaning inside a double-quoted expansion like "${v%pat}".
PR: bin/117748 Exp-run done by: erwin (with some other sh(1) changes)
|
206146 |
03-Apr-2010 |
jilles |
sh: Remove special handling for ' and " in arithmetic. They will be treated like normal characters, resulting in a runtime arithmetic expression error.
Exp-run done by: erwin (with some other sh(1) changes)
|
206145 |
03-Apr-2010 |
jilles |
sh: Fix various things about expansions: * remove the backslash from \} inside double quotes inside +-=? substitutions, e.g. "${$+\}a}" * maintain separate double-quote state for ${v#...} and ${v%...}; single and double quotes are special inside, even in a double-quoted string or here document * keep track of correct order of substitutions and arithmetic
This is different from dash's approach, which does not track individual double quotes in the parser, trying to fix this up during expansion. This treats single quotes inside "${v#...}" incorrectly, however.
This is similar to NetBSD's approach (as submitted in PR bin/57554), but recognizes the difference between +-=? and #% substitutions hinted at in POSIX and is more refined for arithmetic expansion and here documents.
PR: bin/57554 Exp-run done by: erwin (with some other sh(1) changes)
|
206144 |
03-Apr-2010 |
jilles |
sh: Treat unexpected newlines in substitutions as a syntax error.
The old approach was wrong because PS2 was not used and seems unlikely to parse extensions (ksh93's ${ COMMAND} may well fail to parse).
Exp-run done by: erwin (with some other sh(1) changes)
|
205154 |
14-Mar-2010 |
jilles |
sh: Do not abort on a redirection error on a compound command.
Redirection errors on subshells already did not abort the shell because the redirection is executed in the subshell.
Other shells seem to agree that these redirection errors should not abort the shell.
Also ensure that the redirections will be cleaned up properly in cases like command eval '{ shift x; } 2>/dev/null'
Example: { echo bad; } </var/empty/x; echo good
|
205138 |
13-Mar-2010 |
jilles |
sh: Do not abort on a redirection error if there is no command word.
Although simple commands without a command word (only assignments and/or redirections) are much like special builtins, POSIX and most shells seem to agree that redirection errors should not abort the shell in this case. Of course, the assignments persist and assignment errors are fatal.
To get the old behaviour portably, use the ':' special builtin. To get the new behaviour portably, given that there are no assignments, use the 'true' regular builtin.
|
205130 |
13-Mar-2010 |
jilles |
sh: Fix longjmp clobber warnings in parser.c.
Make parsebackq a function instead of an emulated nested function. This puts the setjmp usage in a smaller function where it is easier to avoid bad optimizations.
|
204802 |
06-Mar-2010 |
jilles |
sh: Make sure to popredir() even if a function caused an error.
|
204801 |
06-Mar-2010 |
jilles |
sh: Make sure to popredir() even if a special builtin caused an error.
|
204800 |
06-Mar-2010 |
jilles |
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)
|
204276 |
24-Feb-2010 |
jh |
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
|
203576 |
06-Feb-2010 |
jilles |
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.
|
201431 |
03-Jan-2010 |
jilles |
sh: Send the "not found" message for builtin <cmd> to redirected fd 2.
|
201366 |
01-Jan-2010 |
jilles |
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
|
201355 |
31-Dec-2009 |
jilles |
sh(1): document ulimit -w (swapuse rlimit).
MFC after: 1 week
|
201354 |
31-Dec-2009 |
jilles |
sh(1): Correct two places where "$@" lacked necessary quotes.
MFC after: 1 week
|
201344 |
31-Dec-2009 |
jilles |
sh: Use PATH= assignment in type.
Example: PATH=/var/empty; PATH=/bin type ls
|
201343 |
31-Dec-2009 |
jilles |
sh: Allow command -pv and command -pV (lookup using _PATH_STDPATH).
|
201283 |
30-Dec-2009 |
jilles |
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.
|
201262 |
30-Dec-2009 |
jilles |
Fix memory leak when parsing backticks (``).
|
201259 |
30-Dec-2009 |
jilles |
sh: arith: Return only 0 and 1 from && and ||.
This agrees with C, POSIX and other shells.
|
201056 |
27-Dec-2009 |
jilles |
sh: Change varinit to use const better.
|
201053 |
27-Dec-2009 |
jilles |
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"
|
201020 |
26-Dec-2009 |
jilles |
Remove declaration of function that no longer exists.
|
200998 |
25-Dec-2009 |
jilles |
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 .'.
|
200988 |
25-Dec-2009 |
jilles |
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.
|
200967 |
24-Dec-2009 |
jilles |
sh: Add some __dead2 to indicate functions that do not return.
|
200956 |
24-Dec-2009 |
jilles |
sh: Constify various strings.
Most of this is adding const keywords, but setvar() in var.c had to be changed somewhat more.
|
200943 |
24-Dec-2009 |
jilles |
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'
|
199953 |
29-Nov-2009 |
jilles |
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.
|
199660 |
22-Nov-2009 |
jilles |
Fix various things about SIGINT handling: * 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.
|
199647 |
22-Nov-2009 |
jilles |
sh: Ensure the same command input file is on top after executing a builtin.
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.
|
199641 |
21-Nov-2009 |
jilles |
trap: do not consider a bad signal name a fatal error. POSIX explicitly prescribes this. Continue processing any other signals and return status 1.
|
199631 |
21-Nov-2009 |
stefanf |
Handle current work directories of arbitrary length. The argument to cd continues to be limited by PATH_MAX (1024).
Obtained from: NetBSD PR: 104456
|
199629 |
21-Nov-2009 |
jilles |
sh: Some changes to stderr flushing: * 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
|
199282 |
14-Nov-2009 |
jilles |
sh: Allow a newline before "in" in a for command, as required by POSIX.
|
199205 |
11-Nov-2009 |
jilles |
sh: Use sigaction instead of signal/siginterrupt combination.
|
198963 |
05-Nov-2009 |
jilles |
sh: Fix memory leak when using a variable in arithmetic like $((x)).
MFC after: 3 weeks
|
198454 |
24-Oct-2009 |
jilles |
sh: Exempt $@ and $* from set -u
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).
|
198173 |
16-Oct-2009 |
jilles |
sh: Show more information about syntax errors in command substitution: 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.)
|
197848 |
07-Oct-2009 |
jilles |
Clarify quoting of word in ${v=word} in sh(1).
|
197820 |
06-Oct-2009 |
jilles |
sh: Send the "xyz: not found" message to redirected fd 2. 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
|
197691 |
01-Oct-2009 |
jilles |
sh: Disallow mismatched quotes in backticks (`...`).
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
|
197371 |
20-Sep-2009 |
jilles |
Mention that NUL characters are not allowed in sh(1) input.
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
|
196634 |
28-Aug-2009 |
jilles |
sh: Fix crash with empty functions (f() { }) introduced in r196483
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
|
196483 |
23-Aug-2009 |
jilles |
sh: Fix crash when undefining or redefining a currently executing function.
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
|
194977 |
25-Jun-2009 |
jilles |
Fix some weirdnesses in the NetBSD IFS code, 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)
|
194975 |
25-Jun-2009 |
jilles |
Improve IFS expansion using code from NetBSD.
We now pass the ifs.sh testsuite.
PR: standards/79067 Approved by: ed (mentor) (implicit) Obtained from: NetBSD
|
194922 |
24-Jun-2009 |
jilles |
Designate special builtins as such in command -V and type. Also document various properties of special builtins that we implement.
Approved by: ed (mentor) (implicit)
|
194786 |
23-Jun-2009 |
jilles |
Quote -x tracing output so it is unambiguous.
It is usually but not always suitable for re-input to the shell.
Approved by: ed (mentor) (implicit)
|
194774 |
23-Jun-2009 |
jilles |
Do not fork for a subshell if it is the last thing this shell is doing (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)
|
194767 |
23-Jun-2009 |
kib |
Usermode portion of the support for swap allocation accounting: - 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)
|
194765 |
23-Jun-2009 |
jilles |
sh: Improve handling of setjmp/longjmp volatile: - 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)
|
194560 |
20-Jun-2009 |
jilles |
Fix race condition in noclobber option.
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)
|
194516 |
19-Jun-2009 |
jilles |
Fix some issues with quoted output and shorten it in some cases.
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)
|
194406 |
17-Jun-2009 |
jilles |
Properly flush input after an error in backquotes in interactive mode.
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)
|
194128 |
13-Jun-2009 |
jilles |
Avoid leaving unnecessary waiting shells in many forms of sh -c COMMAND.
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)
|
194127 |
13-Jun-2009 |
jilles |
Don't skip forking for an external command if any traps are active.
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)
|
193636 |
07-Jun-2009 |
jilles |
Mention the range for the exit status for the exit special builtin.
The exit status may exceed 255 in some cases (return); even though it seems unwise to rely on this, it is also unwise to assume that $? is always between 0 and 255.
This resolves bin/124748 by documenting that 'exit -1' is not valid.
PR: bin/124748 Approved by: ed (mentor)
|
193225 |
01-Jun-2009 |
rse |
use explicit 'unsigned int' instead of just the implicit-style 'unsigned' to make linting tools (e.g. FlexeLint) happy, too
|
193223 |
01-Jun-2009 |
rse |
align coding style with style(9) to avoid misunderstandings
|
193222 |
01-Jun-2009 |
rse |
correctly test for __GNUC__ macro (non-GCC compilers do not have it defined at all)
|
193221 |
01-Jun-2009 |
rse |
be more type correct and align local ckmalloc() with its underlying malloc(3) by using a "size_t" instead of an "int" argument
|
193185 |
31-May-2009 |
jilles |
sh: Make read's timeout (-t) apply to the entire line, not only the first character.
This avoids using non-standard behaviour of the old (upto FreeBSD 7) TTY layer: it reprocesses the input queue when switching to canonical mode. The new TTY layer does not provide this functionality and so read -t worked very poorly (first character is not echoed, cannot be backspaced but is still read).
This also agrees with what most other shells with read -t do.
PR: bin/129566 Reviewed by: stefanf Approved by: ed (mentor)
|
193169 |
31-May-2009 |
stefanf |
Fix the eval command in combination with set -e. Before this change the shell would always terminate if eval returned with a non-zero exit status regardless if the status was actually tested. Unfortunately a new file-scope variable is needed, the alternative would only be to add a new parameter to all built-ins.
PR: 134881
|
191009 |
13-Apr-2009 |
stefanf |
Parse 'cmd1 && ! cmd2 | cmd3' correctly, the bang should apply to the entire pipeline cmd2 | cmd3 and not just cmd2.
PR: 130298 Submitted by: Jilles Tjoelker
|
190698 |
04-Apr-2009 |
stefanf |
Don't let trailing empty lines overwrite the result of the last command with 0. This affects the built-ins eval, fc, and trap and also the string passed to sh with the -c option.
Submitted by: Jilles Tjoelker
|
190298 |
22-Mar-2009 |
stefanf |
Fix the behaviour of the read built-in when IFS is unset.
Obtained from: NetBSD
|
190295 |
22-Mar-2009 |
stefanf |
Improve the IFS handling of the read built-in.
Obtained from: NetBSD Submitted by: Jilles Tjoelker
|
190284 |
22-Mar-2009 |
stefanf |
- Apply the r190270 changes to printing of single aliases too. - Sort the aliases before printing them.
|
190270 |
22-Mar-2009 |
stefanf |
Make the output of the alias built-in POSIX-compliant: Drop the leading 'alias' and suppress printing the trailing space which is added for internal purposes.
|
189542 |
08-Mar-2009 |
ed |
Don't disable CR-to-NL translation when waiting for data to arrive.
A difference between the old and the new TTY layer is that the new implementation does not perform any post-processing before returning data back to userspace when calling read().
sh(1)'s read turns the TTY into a raw mode before calling select(). This means that the first character will not receive any ICRNL processing. Inherit this flag from the original terminal attributes.
Even though this issue is not present on RELENG_*, I'm MFCing it to make sh(1) in jails behave better.
PR: bin/129566 MFC after: 2 weeks
|
185401 |
28-Nov-2008 |
stefanf |
Report error messages of the builtins 'type' and 'command -V' to stderr instead of stdout.
Noticed by: Zajcev Evgeny
|
185231 |
23-Nov-2008 |
stefanf |
Fix $? at the first command of a function. The previous exit status was saved twice and thus lost.
|
182489 |
30-Aug-2008 |
ed |
Document the ulimit -p option in the sh(1) manual page.
When I imported the MPSAFE TTY code, I added the -p flag to sh(1)'s ulimit, but I forgot to document it in the appropriate manual page.
Requested by: stefanf
|
182300 |
27-Aug-2008 |
stefanf |
Fix a bug in r177497 which caused the getopts state to be reset when 'set' was used to set a shell option (and not to change the positional parameters).
Submitted by: Martin Kammerhofer
|
181905 |
20-Aug-2008 |
ed |
Integrate the new MPSAFE TTY layer to the FreeBSD operating system.
The last half year I've been working on a replacement TTY layer for the FreeBSD kernel. The new TTY layer was designed to improve the following:
- Improved driver model:
The old TTY layer has a driver model that is not abstract enough to make it friendly to use. A good example is the output path, where the device drivers directly access the output buffers. This means that an in-kernel PPP implementation must always convert network buffers into TTY buffers.
If a PPP implementation would be built on top of the new TTY layer (still needs a hooks layer, though), it would allow the PPP implementation to directly hand the data to the TTY driver.
- Improved hotplugging:
With the old TTY layer, it isn't entirely safe to destroy TTY's from the system. This implementation has a two-step destructing design, where the driver first abandons the TTY. After all threads have left the TTY, the TTY layer calls a routine in the driver, which can be used to free resources (unit numbers, etc).
The pts(4) driver also implements this feature, which means posix_openpt() will now return PTY's that are created on the fly.
- Improved performance:
One of the major improvements is the per-TTY mutex, which is expected to improve scalability when compared to the old Giant locking. Another change is the unbuffered copying to userspace, which is both used on TTY device nodes and PTY masters.
Upgrading should be quite straightforward. Unlike previous versions, existing kernel configuration files do not need to be changed, except when they reference device drivers that are listed in UPDATING.
Obtained from: //depot/projects/mpsafetty/... Approved by: philip (ex-mentor) Discussed: on the lists, at BSDCan, at the DevSummit Sponsored by: Snow B.V., the Netherlands dcons(4) fixed by: kan
|
181269 |
04-Aug-2008 |
cperciva |
Mark functions as __dead2 in order to help the LLVM static checker understand which code paths aren't possible.
This commit eliminates 117 false positive bug reports of the form "allocate memory; error out if pointer is NULL; use pointer".
|
181017 |
30-Jul-2008 |
stefanf |
Pass the correct flags to expandarg() for NFROMFD and NTOFD. This fixes a segmentation fault when the argument expands to an empty string.
Reported by: simon MFC after: 3 weeks
|
179639 |
07-Jun-2008 |
rse |
use 'const' for the parameters of the two static functions unalias() and hashalias()
|
179638 |
07-Jun-2008 |
rse |
remove an unnecessary include
|
179387 |
28-May-2008 |
stefanf |
Fix checking if a variable name is LINENO. As STPUTC changes the pointer if it needs to enlarge the buffer, we must not keep a pointer to the beginning.
PR: ports/123879
|
179022 |
15-May-2008 |
stefanf |
Expand $LINENO to the current line number. This is required by SUSv3's "User Portability Utilities" option.
Often configure scripts generated by the autotools test if $LINENO works and refuse to use /bin/sh if not.
Package test run by: pav
|
178631 |
28-Apr-2008 |
stefanf |
Sigh, when reapplying the patch to HEAD, I somehow forgot to commit this file.
Reported by: Jaakko Heinonen
|
178625 |
27-Apr-2008 |
stefanf |
- Fix bugs where the value of arithmetic expansion$((...)) was trucated to type int. - Change the type used for arithmetic expansion to intmax_t (ie. 64 bit on all currently supported FreeBSD architectures). SUSv3 requires at least type long but allows for larger types. Other shells (eg. bash, zsh, NetBSD's sh) do that too.
PR: 122659 Submitted by: Jaakko Heinonen (minor modifications by me)
|
177497 |
22-Mar-2008 |
stefanf |
Reset the internal state used for the 'getopts' built-in when 'shift' or 'set' are used to modify the arguments. Not doing so caused random memory reads or null pointer dereferences when 'getopts' was called again later (SUSv3 says getopts produces unspecified results in this case).
PR: 48318
|
176521 |
24-Feb-2008 |
stefanf |
Split updatepwd() into two smaller functions. The first one, findpwd(), computes the new path and the second one, updatepwd(), updates the variables PWD, OLDPWD and the path used for the pwd builtin according to the new directory. For a logical directory change, chdir() is now called between those two functions, no longer causing wrong values to be stored in PWD etc. if it fails.
PR: 64990, 101316, 120571
|
176392 |
18-Feb-2008 |
marcel |
Fix "warning: comparison is always false due to limited range of data type" on platforms with unsigned chars. The comparison in question is there to determine whether chars are unsigned or not and is based on comparing a char, initialized to -1, for less than 0. Change the comparison to check for geater than 0 instead...
|
174287 |
05-Dec-2007 |
ru |
Revise the markup.
|
173718 |
18-Nov-2007 |
jb |
Reduce the WARNS level to avoid a compiler warning about a variable possibly being clobbered by a longjmp or a fork with gcc4.
|
172440 |
04-Oct-2007 |
stefanf |
The exit status of a case statement where none of the patterns is matched is supposed to be 0, not the status of the previous command.
Reported by: Eygene Ryabinkin PR: 116559 Approved by: re (gnn)
|
171268 |
06-Jul-2007 |
scf |
Take care that the input to setenv() may actually be a pointer straight from environ; make a copy before manipulating it and passing it to setenv().
Approved by: wes Approved by: re (kensmith)
|
171195 |
04-Jul-2007 |
scf |
Significantly reduce the memory leak as noted in BUGS section for setenv(3) by tracking the size of the memory allocated instead of using strlen() on the current value.
Convert all calls to POSIX from historic BSD API: - unsetenv returns an int. - putenv takes a char * instead of const char *. - putenv no longer makes a copy of the input string. - errno is set appropriately for POSIX. Exceptions involve bad environ variable and internal initialization code. These both set errno to EFAULT.
Several patches to base utilities to handle the POSIX changes from Andrey Chernov's previous commit. A few I re-wrote to use setenv() instead of putenv().
New regression module for tools/regression/environ to test these functions. It also can be used to test the performance.
Bump __FreeBSD_version to 700050 due to API change.
PR: kern/99826 Approved by: wes Approved by: re (kensmith)
|
169177 |
01-May-2007 |
ache |
Back out all POSIXified *env() changes.
Not because I admit they are technically wrong and not because of bug reports (I receive nothing). But because I surprisingly meets so strong opposition and resistance so lost any desire to continue that.
Anyone who interested in POSIX can dig out what changes and how through cvs diffs.
|
169133 |
30-Apr-2007 |
ache |
Simplify previous fix and disallow VTEXTFIXED direct pass for putenv() too, just use savestr()
|
169118 |
30-Apr-2007 |
ache |
Put some safeguards: 1) Under POSIX unsetenv("foo=bar") is explicit error and not equal to unsetenv("foo") 2) Prepare for upcomig POSIXed putenv() rewrite: make putenv() calls portable and conforming to standard.
|
166101 |
18-Jan-2007 |
stefanf |
Use eaccess() instead of access() for the type builtin, like we do for the test builtin.
Submitted by: Martin Kammerhofer
|
165930 |
11-Jan-2007 |
stefanf |
Return an error status (127) from the builtins 'type' and 'command' (with either -v or -V) if a file with a slash in the name doesn't exist (if there is no slash we already did that).
Additionally, suppress the error message for command -v for files with a slash.
PR: 107674 Submitted by: Martin Kammerhofer
|
164081 |
07-Nov-2006 |
stefanf |
Fix expanding of quoted positional parameters in case patterns.
Obtained from: NetBSD (expand.c 1.58 and 1.59) Submitted by: Paul Jarc PR: 56147
|
164003 |
05-Nov-2006 |
stefanf |
When parsing an invalid parameter expansion (eg. ${} or ${foo@bar}) do not issue a syntax error immediately but save the information that it is erroneous for later when the parameter expansion is actually done. This means eg. "false && ${}" will not generate an error which seems to be required by POSIX. Include the invalid parameter expansion in the error message (sometimes abbreviated with ... because recovering it would require a lot of code).
PR: 105078 Submitted by: emaste
|
163085 |
07-Oct-2006 |
stefanf |
Add the POSIX option -p to the jobs builtin command. It prints the PID of the process leader for each job. Now the last specified option for the output format (-l, -p or -s) wins, previously -s trumped -l.
PR: 99926 Submitted by: Ed Schouten and novel (patches modified by me)
|
162379 |
17-Sep-2006 |
ru |
Markup fixes.
|
160964 |
04-Aug-2006 |
yar |
Commit the results of the typo hunt by Darren Pilgrim. This change affects documentation and comments only, no real code involved.
PR: misc/101245 Submitted by: Darren Pilgrim <darren pilgrim bitfreak org> Tested by: md5(1) MFC after: 1 week
|
160849 |
31-Jul-2006 |
yar |
Do not forget to increment the input line counter when reading a word spanning multiple lines.
PR: bin/101094 MFC after: 5 days
|
160812 |
29-Jul-2006 |
yar |
Tell more of the sh(1) history. Acknowledge Kenneth Almquist's contribution in AUTHORS.
MFC after: 5 days
|
160694 |
26-Jul-2006 |
yar |
Make it easier to find that we have test(1) built-in in sh(1).
MFC after: 3 days
|
159836 |
21-Jun-2006 |
yar |
Document the fact that 'true' and 'false' are among sh(1) built-in commands.
MFC after: 3 days
|
159633 |
15-Jun-2006 |
stefanf |
Merge NetBSD's revision 1.86: Don't crash on "<cmd> | { }".
|
159632 |
15-Jun-2006 |
stefanf |
Implement the PS4 variable which is defined by the POSIX User Portability Utilities option. Its value is printed at the beginning of the line if tracing (-x) is active. PS4 defaults to the string "+ " which is compatible with the old behaviour to always print "+ ".
We still need to expand variables in PS1, PS2 and PS4.
PR: 46441 (part of) Submitted by: schweikh Obtained from: NetBSD
|
159551 |
12-Jun-2006 |
stefanf |
Don't strip a leading ./ from the path for the cd builtin to avoid interpreting .//dir as /dir. Rather strip it only for the purpose of checking if the directory path should be printed.
PR: 88813 Submitted by: Josh Elsasser Patch from: NetBSD (cd.c rev 1.38) MFC after: 2 weeks
|
158145 |
29-Apr-2006 |
stefanf |
POSIX demands that set's output (when invoked without arguments) should be sorted. Sort the variables before printing.
PR: 96415
|
158143 |
29-Apr-2006 |
stefanf |
Check the buffer size when copying the line returned by el_gets() into our own buffer. Interactively typing in long lines (>1023 characters) previously overflowed the buffer. Unlike the NetBSD people I don't see the need to subtract 8 from BUFSIZ, so I just used BUFSIZ-1.
Obtained from: NetBSD PR: 91110
|
157811 |
17-Apr-2006 |
schweikh |
Whitespace nits.
|
157789 |
16-Apr-2006 |
schweikh |
Correct assorted grammos and typos.
|
157750 |
14-Apr-2006 |
schweikh |
Output something reasonable for regular and expanded here-documents. I would have chosen the EOF markers, but they are no longer available AFAICS, so output "<<HERE" and "<<XHERE" instead. (NOTE: These changes only affect DEBUG output.)
|
157601 |
09-Apr-2006 |
stefanf |
Implement some of the differences between special built-ins and other builtins demanded by POSIX. - A redirection error is only fatal (meaning the execution of a shell script is terminated) for special built-ins. Previously it was fatal for all shell builtins, causing problems like the one reported in PR 88845. - Variable assignments remain in effect for special built-ins. - Option or operand errors are only fatal for special built-ins. This change also makes errors from 'fc' non-fatal (I could not find any reasons for this behaviour).
Somewhat independently from the above down-grade the error handling in the shift built-in if the operand is bigger than $# from an error() call (which is now fatal) to a return 1. I'm not sure if this should be considered a POSIX "operand error", however this change is needed for now as we trigger that error while building libncurses. Comparing with other shells, zsh does the same as our sh before this change (write a diagnostic, return 1), bash behaves as our sh after this commit (no diagnostic, return 1) and ksh93 and NetBSD's sh treat it as a fatal error.
|
157414 |
02-Apr-2006 |
stefanf |
Issue an error when . (dot) is invoked without a filename. The synopsis is just ". file" according to POSIX, however many other shells allow arguments to be passed after the file. For compatibility (we even use that feature in buildworld) additional arguments are not considered to be an error, even though this shell does not do anything with the arguments at all.
|
157413 |
02-Apr-2006 |
stefanf |
Use -s to flag POSIX's "special built-in" utilities in builtins.def. Add a new member to struct builtincmd and set it to 1 if -s was specified. This is done because there are cases where special builtins must be treated differently from other builtins.
Obtained from: NetBSD (builtins.def part)
|
155304 |
04-Feb-2006 |
schweikh |
Initialize PWD early on (don't expect it to be inherited from the environment or set it only when changing directories with cd).
PR: standards/92640
|
155303 |
04-Feb-2006 |
schweikh |
s/staticly/statically/g
|
155302 |
04-Feb-2006 |
schweikh |
s/varable/variable/; s/tored/stored/
|
155301 |
04-Feb-2006 |
schweikh |
Remove some white space at EOL.
|
153951 |
01-Jan-2006 |
stefanf |
Document that '#' starts a comment.
PR: 85103 Submitted by: garys Obtained from: pdksh manual Patch from: Daniel Gerzo (with changes by me)
|
153417 |
14-Dec-2005 |
maxim |
o Now when SIG_IGN signal action for SIGCHLD reap zombies automatically it is possible wait4(2) returns -1 and sets errno = ECHILD if there were forked children. A user can set such signal handler e.g. via ``trap "" 20'', see a PR for the test case. Deal with this case and mark a job as JOBDONE.
PR: bin/90334 Submitted by: bde MFC after: 4 weeks
|
153246 |
08-Dec-2005 |
stefanf |
- Document trap's -l option and the behaviour of a missing action or a single dash. - Discourage the omission of the action.
PR: 70985 [1] Submitted by: Martin Kammerhofer
|
153245 |
08-Dec-2005 |
stefanf |
Print empty quotes ('') when an empty string is passed to outqstr(). This makes a difference for the trap builtin, where after "trap '' 0" we printed "trap -- quit". This is wrong, because an empty action means to reset the action to the default. A side effect of this commit is that empty variables are now printed as "variable=''" instead of just "variable=".
|
153244 |
08-Dec-2005 |
stefanf |
Correctly quote the output when showing the installed trap actions.
PR: 74043 Submitted by: Jilles Tjoelker
|
153240 |
08-Dec-2005 |
stefanf |
Clarify that the echo builtin takes an arbitrary number of strings. Mention that spaces are printed between the strings.
|
153094 |
04-Dec-2005 |
stefanf |
Sort.
|
153093 |
04-Dec-2005 |
stefanf |
Remove a few commented out builtins from the original ash. The files implementing them were never part of FreeBSD.
|
153091 |
04-Dec-2005 |
stefanf |
Add the times builtin. It reports the user and system time for the shell itself and its children. Instead of calling times() (as implied by POSIX) this implementation directly calls getrusage() to get the times because this is more convenient.
|
152547 |
17-Nov-2005 |
ru |
-mdoc sweep.
|
151984 |
03-Nov-2005 |
jcamou |
Add `local' and `return' to the list of built-ins.
Submitted by: garys Approved by: trhodes (mentor)
|
151866 |
29-Oct-2005 |
stefanf |
Include disabled options in the output of 'set +o'. POSIX says the output of set +o can be used to reload previous settings, for this to work disabled options must be printed as well or otherwise options that were set in the mean time won't be turned off.
To avoid an excessively long output line I formatted the output to print only six options per line.
Submitted by: Jilles Tjoelker PR: 73500
|
151858 |
29-Oct-2005 |
stefanf |
Document command -v and -V.
Glanced at by: simon
|
151856 |
29-Oct-2005 |
stefanf |
Document that read -t timeout returns 1 if the timeout elapses.
|
151810 |
28-Oct-2005 |
stefanf |
Add the POSIX options -v and -V to the 'command' builtin. Both describe the type of their argument, if it is a shell function, an alias, a builtin, etc. -V is more verbose than -v.
PR: 77259, 84539
|
151795 |
28-Oct-2005 |
stefanf |
Protect malloc, realloc and free calls with INT{ON,OFF} directly in chkalloc, 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
|
151471 |
19-Oct-2005 |
stefanf |
Use the new name H_SETSIZE instead of the old H_EVENT to set the history size.
PR: 86355
|
149938 |
10-Sep-2005 |
stefanf |
Elaborate on the behaviour of set -e.
|
149933 |
10-Sep-2005 |
stefanf |
Pass the EV_TESTED flag to evalloop() and evalfor(). This fixes unwanted termination with set -e if a command fails in a loop body inside a function with an explicitely tested exit status, eg
f() { for i in 1 2 3; do false done } f || true
Briefly reviewed by: cracauer
|
149932 |
10-Sep-2005 |
stefanf |
Pass the EV_TESTED flag to the left operand of NSEMI nodes. This fixes two cases of unwanted termination with set -e:
* if-commands containing several commands separated by semicolons, eg
if false; false; then [...]
* functions with an explicitely tested exit status that contain a failing command which is not the last one, eg
f() { false false } f || true
PR: 77067, 85267 Briefly reviewed by: cracauer
|
149927 |
10-Sep-2005 |
stefanf |
Exit the shell if a pipeline that is not preceded by ! fails and set -e is active. Use a separate flag to avoid adding another condition to the if-statement at the end of evaltree().
Briefly reviewed by: cracauer
|
149920 |
09-Sep-2005 |
stefanf |
Split the export synopsis into two lines as -p cannot be mixed with variable names.
|
149919 |
09-Sep-2005 |
stefanf |
- Provide a reasonable error message for `export -p var'. - Use argv rather than argptr since getopt() is used here.
|
149918 |
09-Sep-2005 |
stefanf |
Fix the error message if the mask that is passed to umask -S contains non-digits.
|
149825 |
06-Sep-2005 |
rse |
Various small code cleanups resulting from a code reviewing 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@
|
149816 |
06-Sep-2005 |
rse |
fix typo: ommitted -> omitted
|
149802 |
05-Sep-2005 |
stefanf |
Print pointers with %p rather than casting them to long.
|
149763 |
03-Sep-2005 |
stefanf |
Document that `in word ...' is optional in the for command.
|
149743 |
02-Sep-2005 |
stefanf |
Return 1 from the unalias builtin if _any_ removal fails, not just the last one.
|
149742 |
02-Sep-2005 |
stefanf |
Remove extra getenv() declaration.
|
149740 |
02-Sep-2005 |
stefanf |
Document that unalias can be used to remove several alias names.
|
149604 |
29-Aug-2005 |
jcamou |
Wrap a line due to a new sentence.
Noticed by: simon Approved by: trhodes (mentor)
|
149562 |
29-Aug-2005 |
jcamou |
o Discuss the ways to escape an alias. o Fix the alias syntax lines. o Refer to the Aliases subsection.
PR: docs/84914 Submitted by: garys Approved by: trhodes (mentor) MFC after: 3 days
|
149209 |
17-Aug-2005 |
stefanf |
Document umask's -S option.
|
149096 |
15-Aug-2005 |
stefanf |
Remove a hack for an ancient gdb.
|
149046 |
14-Aug-2005 |
stefanf |
Recent cleanups made it possible to bump WARNS to 3.
|
149026 |
13-Aug-2005 |
stefanf |
Put the comparison with PEOF into a new macro is_eof(). Don't use it if the character comes from a string.
|
149025 |
13-Aug-2005 |
stefanf |
Declare echocmd() and testcmd().
|
149024 |
13-Aug-2005 |
stefanf |
Use assignment rather than comparison.
|
149019 |
13-Aug-2005 |
stefanf |
- Provide all initialisers for a struct event. - Include init.h in the generated init.c. - Generate prototypes and put the brace on the next line.
|
149018 |
13-Aug-2005 |
stefanf |
First declare the functions to pacify -Wmissing-prototypes.
|
149017 |
13-Aug-2005 |
stefanf |
Include missing headers.
|
149016 |
13-Aug-2005 |
stefanf |
Use prototypes in the MKINIT lines collected by mkinit.
|
149015 |
13-Aug-2005 |
stefanf |
Use prototypes in the generated builtins.{c,h} files.
|
149012 |
13-Aug-2005 |
stefanf |
cvs -d stefanf@ncvs.FreeBSD.org:/home/ncvs
|
148974 |
11-Aug-2005 |
stefanf |
El_parse's third parameter is now const-qualified, add a cast.
|
147812 |
07-Jul-2005 |
delphij |
Fix a bug when shell expansion is done against dangling symlinks, by converting the stat() call to a lstat() call, which will cover the situation. One can exercise this bug by referring a dangling link with something like */the-link.
Approved by: re (scottl) Submitted by: Simon 'corecode' Schubert [corecode fs ei tum de] Obtained from: NetBSD via DragonFlyBSD (NetBSD rev. 1.51 and DragonFly rev. 1.6) MFC After: 3 days
|
147362 |
14-Jun-2005 |
ru |
Sorted sections and fixed prompt (PS[12]) strings.
Approved by: re (blanket)
|
147361 |
14-Jun-2005 |
ru |
Put the description of the -c option in the right place, as promised by the Argument List Processing section introduction. What follows the option in the options list is its long name, not its argument (as is the case for the -c option). Also sort references in the SEE ALSO section.
Approved by: re (blanket)
|
146255 |
16-May-2005 |
gad |
A second attempt to adjust option-parsing on a shell command, for the benefit of scripts start out as: #!/bin/sh -- # -*- perl -*- With this fix in place, we can commit a change to kern/imgact_shell.c so FreeBSD will process the `#!' line in shell-scripts in a more standard fashion.
PR: 16393 Mentioned on: freebsd-arch
|
145115 |
15-Apr-2005 |
keramida |
Various sh(1) enhancements: - Move the description of the ``-c string'' option closer to the option itself. - Add an ENVIRONMENT section (1) - Add more .Xr cross references to the SEE ALSO section.
Obtained from: NetBSD (1)
|
143125 |
04-Mar-2005 |
keramida |
Use ``.Pq Ql'' to quote single characters, instead of ``.Pq Li''. This makes the resulting output more aesthetically pleasing in text-only terminals:
Reviewed by: ru
|
143124 |
04-Mar-2005 |
keramida |
Add a section describing the exit status of the shell.
Obtained from: NetBSD
|
142845 |
01-Mar-2005 |
obrien |
Support \H, \h, \w, \W, \$ string expansion in the prompt.
Submitted by: mini
|
141962 |
16-Feb-2005 |
gad |
Change /bin/sh so *it* implements the processing needed for scripts to work as expected when they have a "shebang line" of:
#!/bin/sh -- # -*- perl -*- -p
This specific line is recommended in some perl documentation, and I think I've seen similar lines in documentation for ruby and python. Those write-ups expect `sh' to ignore everything after the '--' if the first thing after the '--' is a '#'. See chapter 19, "The Command-Line Interface" in 3rd edition of "Programming Perl", for some discussion of why perl recommends using this line in some circumstances.
The above line does work on solaris, irix and aix (as three data points), and it used to work on FreeBSD by means of a similar patch to execve(). However, that change to execve() effected *all* shells (which caused other problems), and that processing was recently removed.
PR: 16393 (the original request to fix the same issue) Reviewed by: freebsd-current (looking at a slightly different patch) MFC after: 1 week
|
139969 |
10-Jan-2005 |
imp |
/*- or .\"- or #- to begin license clauses.
|
139943 |
09-Jan-2005 |
ru |
Scheduled mdoc(7) sweep.
|
139673 |
04-Jan-2005 |
ceri |
Correct typo.
|
138313 |
02-Dec-2004 |
maxim |
o Add a missed "." .
Reviewed by: ru MFC after: 3 weeks
|
138312 |
02-Dec-2004 |
maxim |
o Terminate an endless loop sh -T goes into in dowait() around waitproc().
XXX from Tor: "The shell can also go into a similar loop if the child was killed by signal 127, since the shell would believe the child to have only stopped (WIFSTOPPED() macro returns nonzero value). Disallowing signals 127 and 128 will fix that problem." See kern/19402 for details.
PR: bin/66242 Submitted by: tegge Analysis and testcase by: demon MFC after: 3 weeks
|
137113 |
01-Nov-2004 |
alfred |
When listing the special $ variables, ($!, $#, etc) list them as $! instead of just !, this allows one to more easily locate/understand the section of the manpage in question.
Additional wording correction by: keramida Reviewed by: keramida
|
135856 |
27-Sep-2004 |
des |
Attempting to unset an undefined variable or function should not be considered an error according to the Open Group Base Specification.
PR: standards/45738 Submitted by: Matthias Andree <matthias.andree@web.de> MFC after: 3 days
|
131513 |
03-Jul-2004 |
tjr |
Document missing multibyte character handling in utilities specified by POSIX.
|
131505 |
03-Jul-2004 |
ru |
Deal with double whitespace.
|
131484 |
02-Jul-2004 |
ru |
Mechanically kill hard sentence breaks.
|
129647 |
24-May-2004 |
stefanf |
Include <stdio.h> for a sprintf() prototype.
Approved by: das (mentor)
|
128233 |
14-Apr-2004 |
green |
Document the "return" built-in better: it will exit . (sources) and the top-level shell instance, too.
|
127958 |
06-Apr-2004 |
markm |
Remove clause 3 from the UCB licenses.
OK'ed by: imp, core
|
127167 |
18-Mar-2004 |
ru |
Install /bin/sh safely. This allows a shell script to be used to strip binaries by specifying it in the STRIPBIN environment variable honoured by install(1).
MFC after: 3 days
|
126173 |
23-Feb-2004 |
johan |
style.Makefile: Use WARNS?= instead of WARNS=
|
125728 |
12-Feb-2004 |
njl |
style(9): wrap at 80 columns.
|
125727 |
12-Feb-2004 |
njl |
Handle proper formatting and a buffer overrun when running an old sh on a system that has sys_nsig > NSIG (i.e. when libc is upgraded.)
Submitted by: Matt Dillon Reviewed by: bde
|
125503 |
05-Feb-2004 |
ru |
Fixed style of DPADD and LDADD assignments as per style.Makefile(5).
|
125501 |
05-Feb-2004 |
cracauer |
Commit fix sent by Tor Egge <Tor.Egge@cvsup.no.freebsd.org>
Only use return value from system call if system call succeeded.
Tested with `make world` and some of my own scripts.
This should be MFCed soon. While /bin/sh is hard to test the fix is obviously correct and can be assumed not to break something else (famous last words...).
|
125155 |
28-Jan-2004 |
njl |
Use sys_nsig instead of NSIG for the length of the signal arrays. This is important if we add new signals later. From DragonflyBSD: jobs.c:1.4, trap.c:1.3.
Obtained from: DragonflyBSD
|
125153 |
28-Jan-2004 |
cracauer |
The PR diff I committed recently had one bug noticed by Joe Marcus Clarke <marcus@FreeBSD.ORG>, subshells could lose a non-zero exit status.
This commit is Joe's proposed patch. Thanks!
I verified that the problem Joe found is fixed and I ran a full world with this patch.
I don't plan to ever commit language patches to /bin/sh again. It is a minefield too big to navigate without a full-time committment, which I am not willing to do on our /bin/sh.
Under normal circumstances I would recommend using NetBSD's sh which has a lot of language fixes (like the ones what these patches were about) but unfortunately they had implemented broken signal behaviour for shellscript containing interactive programs. Similar issues apply to pdksh which is OpenBSD's sh.
From my perspective bash2 is the only really working bourne sh out there and that one is GPLed. Oh well.
|
124780 |
21-Jan-2004 |
des |
Replace home-grown dup2() implementation with actual dup2() calls. This should slightly reduce the number of system calls in critical portions of the shell, and select a more efficient path through the fdalloc code.
Reviewed by: bde
|
124751 |
20-Jan-2004 |
ru |
Removed duplicate y.tab.h from SRCS and CLEANFILES.
|
123996 |
30-Dec-2003 |
maxim |
o Spell 'diretories' correctly.
PR: misc/60730 Submitted by: Eugene Grosbein MFC after: 3 days
|
123921 |
28-Dec-2003 |
cracauer |
PR 28852
sh -e behaviour was incorrect when && and || statements where used in "if" clauses.
This is the patch submitted by MORI Kouji <mori@tri.asanuma.co.jp>.
It fixes the issue at hand, but sh fixes like this are super-hard to verify that they don't break anything else. I ran some of my old test cases and a few big GNU configure scripts that detected mistakes before, with the previous sh, patched sh and bash. No differences in behaviour found. MFC recommended after longer than usual time.
Compiles on i386 and sledge.
|
120023 |
13-Sep-2003 |
schweikh |
Do not assume there is only a space between #define and the macro name when grepping for JOBS. The recent style cleanup replaced the space with a tab and broke job control detection. Little edits, disastrous consequences.
Submitted by: Peter Edwards <pmedwards@eircom.net> X-MFC when: in about 5 weeks with the other sh arithmetic fixes.
|
119893 |
08-Sep-2003 |
ru |
mdoc(7): Use the new feature of the .In macro.
|
119835 |
07-Sep-2003 |
schweikh |
Fix testing of arith_assign() value for $((a=15)).
Submitted by: Enache Adrian <enache@rdslink.ro>
|
119799 |
06-Sep-2003 |
tjr |
#include <string.h> for prototypes for strcpy() and strlen().
Submitted by: Stefan Farfeleder
|
119746 |
04-Sep-2003 |
schweikh |
Style cleanup, mostly
Requested by: bde
|
119578 |
30-Aug-2003 |
schweikh |
Implement missing shell arithmetic operators in $(()) expansion and variable recognition.
PR: standards/52972 Submitted by: Wartan Hachaturow <wart@tepkom.ru> Reviewed by: tjr (improved on original patch) Tested by: buildworld on CURRENT. MFC after: 6 weeks
|
118374 |
03-Aug-2003 |
ache |
Remove collate_range_cmp() stabilization, it conflicts with ranges
|
117261 |
05-Jul-2003 |
dds |
Changes following CScout analysis:
- Removed dead declarations - Made objects that should have been declared as static, static.
The changes use STATIC instead of static, following the existing convention in the rest of the code.
Approved by: schweikh (mentor) MFC after: 2 weeks
|
115424 |
31-May-2003 |
fenner |
Instead of eating trailing newlines after inserting them into the output buffer, don't insert them at all. This prevents a buffer *underrun* when the substitution consists completely of newlines (e.g. `echo`) and the byte before the source buffer to which p points is a '\n', in which case more characters would be removed from the output buffer than were inserted.
This fixes certain port builds on sparc64.
Approved by: re (scottl) Reviewed by: des, tjr
|
115082 |
16-May-2003 |
ru |
mdoc(7) police: A better version of the same.
Approved by: re (blanket)
|
114763 |
05-May-2003 |
obrien |
Centralize _PATH_* definitions.
Submitted by: Tim Kientzle <kientzle@acm.org> (embellished by me)
|
114500 |
02-May-2003 |
obrien |
The is_name and is_in_name macros are FUBAR'ed. Due to the use of signed vs. unsigned chars on our various platforms, one gets "warning: comparison is always true due to limited range of data type" from GCC 3.3.
|
114433 |
01-May-2003 |
obrien |
Quiet warnings about copyright[].
|
114318 |
30-Apr-2003 |
schweikh |
Fix references to non-existing or obsoleted man pages.
PR: docs/51480 (only a small part) Submitted by: Diomidis D. Spinellis <dds@aueb.gr>
|
113379 |
12-Apr-2003 |
tjr |
Document the -L and -P options to the cd and pwd commands as being mutually exclusive. The fact that the most recent one specified on the command line is the one that takes effect is an implementation detail and users should not rely on this.
|
112341 |
17-Mar-2003 |
tjr |
Flush the output buffers before forking a child process to avoid the child process writing data that the parent should have written.
PR: 50051 MFC after: 2 weeks
|
112254 |
15-Mar-2003 |
ru |
Fixed (soon might be fatal) -Wformat warnings.
|
111422 |
24-Feb-2003 |
marcel |
Third attempt at removing machdep.h and using ALIGN from <sys/param.h>. The initial stack_block is staticly allocated and will be aligned according to the alignment requirements of pointers, which does not necessarily match the alignment enforced by ALIGN. To solve this a more involved change is required: remove the static initial stack and deal with an initial condition of not having a stack at all. This change is therefore more risky than the previous ones, but unavoidable (other than not using the platform default alignment).
Discussed with: tjr Approved and reviewed by: tjr Tested on: alpha, i386, ia64 and sparc64
|
111063 |
18-Feb-2003 |
tjr |
Revert ALIGN change for the second and last time. I can't figure out why this is breaking sparc64.
|
111025 |
17-Feb-2003 |
tjr |
Second attempt at removing machdep.h and using ALIGN from <sys/param.h>. The problem with the previous attempt, as noticed by Marcel, was that stacknxt was being aligned to a pointer boundary instead of an ALIGNBYTES + 1 boundary, which broke sparc64.
|
110981 |
16-Feb-2003 |
tjr |
Temporarily back out machdep.h/ALIGN changes. It seems that on sparc64, using the alignment from sys/param.h (16) instead of the alignment from machdep.h (8) tickled a nasty bug in the memory allocator that I haven't been able to track down yet.
|
110888 |
14-Feb-2003 |
tjr |
Use the ALIGN macro from <sys/param.h> instead of defining our own incorrect version in machdep.h. Delete machdep.h.
|
110392 |
05-Feb-2003 |
charnier |
Add FBSDID.
|
110302 |
03-Feb-2003 |
fanf |
Improve the layout of the description of the various parameter expansion modifiers. The paragraph that explains the difference between ${foo:-bar} and ${foo-bar} etc. was not very visible.
|
109927 |
27-Jan-2003 |
tjr |
Ensure that the TTY file descriptor is greater than or equal to 10 so that it doesn't interfere with the user's redirections.
PR: 47136 MFC after: 1 week
|
109627 |
21-Jan-2003 |
tjr |
Make this compile with DEBUG defined now that WARNS=0 has been removed from the Makefile: - Print pointers with %p instead of %x. - Include missing headers to get prototypes.
Noticed by: benno
|
108935 |
08-Jan-2003 |
tjr |
Do not strip CTL* escapes from redirection filenames in exptilde(), expari(), expbackq() and evalvar(). Similar to revision 1.39. Patch from Tor Egge.
PR: 45349 MFC after: 2 weeks
|
108286 |
26-Dec-2002 |
tjr |
Add the "wordexp" shell built-in command which will be used to implement the POSIX wordexp() function.
|
108257 |
24-Dec-2002 |
ru |
mdoc(7) police: Deal with self-xrefs.
|
108216 |
23-Dec-2002 |
ru |
mdoc(7) police: markup nit.
|
108189 |
22-Dec-2002 |
dwmalone |
Use '\033' rather than '\e' as the latter is a gccism.
PR: 46015 Submitted by: Jeroen Ruigrok van der Werven <asmodai@wxs.nl> MFC after: 1 week
|
107993 |
17-Dec-2002 |
trhodes |
The code uses trapsasync, however the manual page uses asynctraps. Fix the manual page to reflect the code.
PR: 45820 Submitted by: Marco Molteni <molter@tin.it> Discussed with: tjr
|
107974 |
17-Dec-2002 |
fanf |
Document `trap EXIT` and `trap SIGNAME`.
|
107846 |
14-Dec-2002 |
tjr |
When job control is disabled, never show the job id when reporting the status of a background process that has terminated because of a signal.
|
107631 |
05-Dec-2002 |
ru |
Capitalize ASCII code names.
Approved by: re
|
106192 |
30-Oct-2002 |
tjr |
Delete worthless comments.
|
105389 |
18-Oct-2002 |
tjr |
Avoid accidentally making "-h" a synonym for "fc".
Obtained from: NetBSD
|
104672 |
08-Oct-2002 |
tjr |
Do not strip CTL* escapes from redirection filenames in argstr(); they are later stripped with rmescapes() in expandarg(). If the filename has already been unescaped, doing it again in rmescapes() can walk off the end of the string, leading to memory corruption and eventually SIGSEGV.
Noticed by: kris
|
104554 |
06-Oct-2002 |
tjr |
Disallow empty condition parts of "if", "while" and "until" compound commands. Commands like "if then ... fi" and "while do ... done" are no longer accepted. Bodies of compound commands are still allowed to be empty, because even though POSIX does not allow them, most shells do.
|
104367 |
02-Oct-2002 |
tjr |
Use %d in a printf() format string and cast the argument to int instead of using %td when we know that the number is between 0 and 9; mksyntax is a build tool and needs to work on -stable.
|
104289 |
01-Oct-2002 |
tjr |
Back out experimental changes to fmtstr() that I didn't mean to include in the previous commit.
|
104286 |
01-Oct-2002 |
tjr |
Replace a home-grown printf() clone with a fwopen() wrapper around libc's vfprintf() that writes to a `struct output' instead of a file. Inspired by NetBSD's similar changes (they used asprintf() instead).
|
104284 |
01-Oct-2002 |
mux |
It is now safe to remove WARNS=0 and WFORMAT=0.
Tested on: alpha, i386, sparc64
|
104283 |
01-Oct-2002 |
tjr |
Restore "not found" error message when searching for (or executing) a program fails because the file or a path component does not exist.
Suggested by: bde
|
104282 |
01-Oct-2002 |
mux |
- Don't use quad_t when we really mean rlim_t. - Cast rlim_t to intmax_t when printing it.
This should fix the last format errors in sh(1).
Tested on: i386, sparc64
|
104276 |
01-Oct-2002 |
tjr |
Add back WARNS=0 and WFORMAT=0; gcc is finding nonexistent format string errors with %qd formats.
|
104275 |
01-Oct-2002 |
mux |
Use the %t format modifier to print differences between pointers. This fixes two format warnings on 64 bits archs which are fatal now that WFORMAT=0 has been removed.
It doesn't fully fix the sh(1) build on 64 bits platforms though, there is still some quad_t issues that need to be fixed.
Tested on: i386, sparc64
|
104273 |
01-Oct-2002 |
tjr |
Remove WARNS=0 and WFORMAT=0. The shell compiles cleanly at WARNS=2 on at least i386. If there are warnings on other archs, I'd rather hear about them than pretend they didn't exist.
|
104261 |
01-Oct-2002 |
tjr |
Remove some kind of profiling support that required the 4.2BSD monitor() function in libc.
|
104255 |
01-Oct-2002 |
tjr |
Remove bits and pieces of support for atty, which was made obsolete by adding history and vi/emacs-style line editing to the shell itself. Atty was a user-mode terminal emulator (like screen and window) that did line editing and history.
|
104208 |
30-Sep-2002 |
tjr |
Callers of error() don't need to supply a program name prefix in the error message. Stops ulimit giving error messages like "ulimit: ulimit: xyz".
|
104207 |
30-Sep-2002 |
tjr |
Allow a left parenthesis before patterns in case blocks. POSIX requires us to accept this, but I've never seen a script that uses it.
|
104202 |
30-Sep-2002 |
tjr |
Allow empty case/esac statements; POSIX requires this, and recent versions of autoconf are generating scripts that use this feature.
PR: 43275 35879 Submitted by: Dan Nelson <dnelson@allantgroup.com>
|
104141 |
29-Sep-2002 |
tjr |
Remove dead code which supported systems without O_APPEND, O_CREAT or SIGTSTP.
|
104132 |
29-Sep-2002 |
tjr |
Convert the remaining callers of errmsg() to use strerror(), and remove errmsg() and its table of error messages.
|
103223 |
11-Sep-2002 |
nectar |
Correct a usage of fnctl that could not be right and results in a no-op. I assume it was meant that the close-on-exec flag be set here.
|
102576 |
29-Aug-2002 |
keramida |
Add <stdlib.h> to get a prototype for exit().
Reviewed by: tjr
|
102410 |
25-Aug-2002 |
charnier |
Replace various spellings with FALLTHROUGH which is lint()able
|
102363 |
24-Aug-2002 |
tjr |
There is a built-in command called "builtin"; spell its name correctly after rev. 1.77 called it "built-in".
|
102351 |
24-Aug-2002 |
tjr |
Don't show the process ID of background jobs that have terminated, for consistency with ksh.
|
102230 |
21-Aug-2002 |
trhodes |
s/filesystem/file system/ as discussed on -developers
|
102223 |
21-Aug-2002 |
schweikh |
Fix a few typos, among them s/builtin/built-in/ (except for the ref to the builtin(1) man page.) This is for consistency with the spelling both proposed by ispell as well as IEEE Std 1003.1-2001.
MFC after: 3 days
|
102051 |
18-Aug-2002 |
tjr |
Avoid accessing the current job's process table in the child part of forkshell() after it has been freed. This caused mysterious behaviour when anything but the first command in a pipeline tried to access the terminal when the `junk' malloc() option was enabled (which is the default).
|
102007 |
17-Aug-2002 |
tjr |
Show job control ID, command text, etc. when foreground processes are suspended. This is a followup to rev. 1.51.
MFC after: 1 week
|
101662 |
11-Aug-2002 |
tjr |
Allow redirections by themselves between "&&" and "||" operators. For example, >/dev/null && echo foo
Pointed out by: FUJISHIMA Satsuki MFC after: 1 week
|
101573 |
09-Aug-2002 |
ru |
mdoc(7) police: tidying.
|
100664 |
25-Jul-2002 |
tjr |
Add a -P/-o physical option which behaves similarly to bash/ksh's options by the same name. This option makes the cd and pwd builtins behave physically (as opposed to logically) by default.
Submitted by: fanf
|
100663 |
25-Jul-2002 |
tjr |
Set opterr to zero to avoid duplicate warnings from getopt(3) for unknown options.
|
100661 |
25-Jul-2002 |
tjr |
Use PATH_MAX instead of a local guess at it, which happened to be incorrect.
Suggested by: fanf
|
100660 |
25-Jul-2002 |
tjr |
pwdcmd()'s argc and argv arguments are no longer unused, remove __unused.
Pointed out by: fanf
|
100588 |
24-Jul-2002 |
tjr |
Avoid calling el_resize() from a signal handler, even though libedit itself does that if you set EL_SIGNAL. Instead, set a flag and check it before calling el_gets(). This is safer, but slower to respond to changes.
Pointed out by: mp
|
100578 |
23-Jul-2002 |
tjr |
Catch SIGWINCH in interactive shells and call el_resize() to update libedit's idea of the window size.
|
100568 |
23-Jul-2002 |
tjr |
Call el_source() to read the contents of .editrc when line editing is enabled.
Obtained from: NetBSD MFC after: 2 weeks
|
100565 |
23-Jul-2002 |
tjr |
Add a `bind' builtin command, which is simply a wrapper around libedit's builtin command of the same name. This allows the key bindings for the shell's line editor to be changed.
MFC after: 2 weeks
|
100483 |
22-Jul-2002 |
tjr |
Don't allow "||" or "&&" to be the first tokens of a command.
PR: 40386 MFC after: 2 weeks
|
100437 |
21-Jul-2002 |
tjr |
Implement the P1003.2 `command' builtin command, which is used to suppress shell function and alias lookup. The -p option has been implemented, the UPE -v and -V options have not. The old `command' command has been renamed to `builtin'.
|
100395 |
20-Jul-2002 |
tjr |
Document that only one of the -n and -e options may be specified for sh(1)'s echo(1) builtin command.
PR: 32935, 40747 MFC after: 1 week
|
100351 |
19-Jul-2002 |
tjr |
Remove broken and incomplete support for old releases of System V, don't support system that implement getcwd(3) with a pipe to /bin/pwd.
|
100315 |
18-Jul-2002 |
tjr |
Don't assume file descriptors fit in a short, use an int instead.
|
100308 |
18-Jul-2002 |
tjr |
Avoid using ints or shorts to store process id's, use pid_t instead. The pgrp member of struct job was declared as a short and could not store every possible process group ID value, the rest of them were benign because pid_t happens to be an int.
|
100305 |
18-Jul-2002 |
tjr |
Make the message that is printed when the foreground process is terminated by a signal the same as pdksh/bash/sh before rev. 1.34.
|
99762 |
11-Jul-2002 |
tjr |
Don't assume the shell's controlling terminal is attached to file descriptor 2. Instead, open /dev/tty. This problem stopped commands in subshells from being executed correctly if standard error was redirected.
PR: 36671 Obtained from: NetBSD (but simplified)
|
99761 |
11-Jul-2002 |
tjr |
Remove support for the "old" tty driver by unifdef -UOLD_TTY_DRIVER; many other parts of the shell are no longer compatible with this, and it makes jobs.c quite cluttered with #ifdef's.
|
99760 |
11-Jul-2002 |
tjr |
When growing the job table, don't relocate the jobmru pointer if it's NULL.
|
99645 |
09-Jul-2002 |
tjr |
Close file descriptors when [n]>&- and [n]<&- redirections are used. This was broken by rev. 1.16.
PR: 40334 MFC after: 1 week
|
99634 |
09-Jul-2002 |
tjr |
Print out commands with NTOFD/NFROMFD redirections that close the descriptors (">&-" or similar) correctly in the jobs(1) command.
|
99267 |
02-Jul-2002 |
dillon |
Fix type-o in last commit in preparation for MFC.
|
99110 |
30-Jun-2002 |
obrien |
Consistently use FBSDID
|
98919 |
27-Jun-2002 |
sheldonh |
Document addition of RLIMIT_VMEM support, added in rev 1.26 of miscbltin.c.
|
98834 |
26-Jun-2002 |
dillon |
Add support for RLIMIT_VMEM. The #ifdef's were already there but getopt() needed to be adjusted.
|
98464 |
20-Jun-2002 |
jmallett |
Remove two unused variables.
|
98463 |
20-Jun-2002 |
jmallett |
Minor const cleanup.
Don't discard qualifiers we don't need to discard.
|
98427 |
19-Jun-2002 |
tjr |
Bring documentation on CDPATH and its effects on cd(1) back into sync with reality (and POSIX): current directory isn't searched unless CDPATH has a "." element or is unset.
PR: 38442 Submitted by: oleg dashevskii <be9@be9.ru> MFC after: 1 week
|
98157 |
13-Jun-2002 |
tjr |
Don't list shell builtins when the hash command is used (SUSv3)
|
97916 |
06-Jun-2002 |
tjr |
Document the -f and -v options of the unset builtin.
|
97915 |
06-Jun-2002 |
tjr |
Quote the output of the no-argument form of the `set' builtin for re-input to the shell.
|
97914 |
06-Jun-2002 |
tjr |
Add the SUSv3 -p ("portable") option to both the export and readonly builtins. This makes export/readonly print lines in the form "export name=value".
|
97909 |
06-Jun-2002 |
tjr |
Don't modify output that is to be quoted if it contains no IFS characters or shell metacharacters.
|
97822 |
04-Jun-2002 |
tjr |
Display job status correctly when a pipeline is suspended.
|
97820 |
04-Jun-2002 |
tjr |
Describe finished jobs as "Done", not "Exit" (SUSv3)
|
97819 |
04-Jun-2002 |
tjr |
Don't output `state' and `current' fields for processes that aren't leaders in -l option to jobs(1).
|
97817 |
04-Jun-2002 |
tjr |
Missing prototypes from previous commit.
|
97816 |
04-Jun-2002 |
tjr |
Correct minor spacing problem in output of jobs -l for pipelines.
|
97815 |
04-Jun-2002 |
tjr |
Quote alias values in the output of the alias(1) builtin so they are suitable for re-input to the shell (SUSv3)
|
97731 |
02-Jun-2002 |
tjr |
Fix typo causing ``fc -e'' to not work correctly. getopt() sets optarg, not shoptarg.
|
97730 |
02-Jun-2002 |
tjr |
Adding an entry to the history with H_ENTER moves libedit's internal history cursor. Reset the cursor after adding the entry to the history when doing ``fc -s'' so the output is correct.
|
97689 |
01-Jun-2002 |
tjr |
Implement $PPID, the parent process ID of the shell.
|
97688 |
01-Jun-2002 |
tjr |
Support the remaining job ID formats required by SUSv3: %+ (current job, same as %%), %- (previous job), %?str (job with "str" in its command name).
|
97669 |
31-May-2002 |
tjr |
Add -s (output PID's only) and -l (show PID's) options to the jobs(1) builtin. Modify the output format to match what SUSv3 requires.
|
97664 |
31-May-2002 |
tjr |
#if JOBS around a job control-related statement to allow compilation with job control disabled.
|
97663 |
31-May-2002 |
tjr |
Break the code to display status info for one job out from showjobs() into showjob(), use it inside dowait() to display status info for consistency, and in a format closer to what the standard requires.
|
97660 |
31-May-2002 |
tjr |
Move job to front of most recently used job list when bg'd or fg'd.
|
97659 |
31-May-2002 |
tjr |
Instead of keeping just the jobid of the most recently bg'd or fg'd job, keep a linked list of the jobs, most recently used first. This is required to support the idea of `previous job', and to allow the jobs fg and bg default to be correct according to POSIX.
|
97465 |
29-May-2002 |
ru |
mdoc(7) police: tidy up the markup a bit.
|
97277 |
25-May-2002 |
tjr |
sh appeared in Version 1, not System V.1.
|
97276 |
25-May-2002 |
tjr |
Implement `set +o', which displays the currently set options in a format suitable for re-input into the shell.
|
97092 |
22-May-2002 |
tjr |
Bring back the cd -L and -P options from revision 1.24, but try harder not to fail when the logical current directory no longer exists. Allow changes to absolute paths when logical cwd is invalid, fall back to physical cd if logical cd fails.
|
97091 |
22-May-2002 |
tjr |
Temporarily back out revision 1.24; it seems to handle the case where the current directory no longer exists incorrectly and breaks `make cleandir'.
|
96980 |
20-May-2002 |
tjr |
Add the SUSv3 -L and -P options to the cd and pwd builtin utilities. `Logical' handling of .. is now the default.
|
96948 |
19-May-2002 |
jmallett |
Remove a small, annoying, nit I ran in to editing this file, a lone tab on a line by itself.
|
96939 |
19-May-2002 |
tjr |
Implement the -u (-o nounset) option, which gives an error message if an unset variable is expanded.
Obtained from: NetBSD (bjh21, christos)
|
96933 |
19-May-2002 |
tjr |
Make the fg and bg commands give the output required by SUSv3. fg outputs the name of the command, bg outputs the name of the command and the job id.
|
96922 |
19-May-2002 |
tjr |
Implement the -C (-o noclobber) option, which prevents existing regular files from being overwritten by shell redirection.
|
96702 |
16-May-2002 |
trhodes |
Consistancy check s/file system/filesystem/
Reviewed by: brian
|
95258 |
22-Apr-2002 |
des |
Usage style sweep: spell "usage" with a small 'u'. Also change one case of blatant __progname abuse (several more remain) This commit does not touch anything in src/{contrib,crypto,gnu}/.
|
94869 |
16-Apr-2002 |
charnier |
Use `The .Nm utility'
|
94775 |
15-Apr-2002 |
greid |
Stop a null pointer dereference in the builtin hash function.
PR: 36141 Approved by: cracauer MFC after: 1 week
|
90832 |
18-Feb-2002 |
imp |
Remove now-obsolete __STDC__ ifdefs, remove redundant NULL definition and include stdlib.h for NULL.
|
90166 |
04-Feb-2002 |
kris |
Lock down with WFORMAT=1 except those directories with unfixed warnings. Tested on i386 and alpha.
|
90112 |
02-Feb-2002 |
imp |
%.* takes an int, not a size_t.
|
90111 |
02-Feb-2002 |
imp |
o __P has been reoved 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) { ...
|
89312 |
13-Jan-2002 |
babkin |
The fix for >/dev/stdout, including Tor Egge's fix for the bug in the original attempt of the fix. And yes, this time I've tried to build world with it and it succeeded.
Submitted by: Tor Egge MFC after: 1 week
|
88463 |
24-Dec-2001 |
alfred |
backout rev 1.14, it's breaking things.
|
88396 |
22-Dec-2001 |
babkin |
Added ability to do ">/dev/stdout". The apsfilter people are anxious to get it MFCed in time for release 4.5.
MFC after: 2 weeks
|
87323 |
04-Dec-2001 |
obrien |
Default to WARNS=2. Binary builds that cannot handle this must explicitly set WARNS=0.
Reviewed by: mike
|
86692 |
20-Nov-2001 |
knu |
Remove the printf builtin command from sh(1), which command is not used so often that it's worth keeping it as a builtin.
Now that all the printf invocations from within the system startup scripts, we can safely remove it.
Urged by: sheldonh :)
No MFC is planned so far because it may break compatibility and violate POLA.
|
86505 |
17-Nov-2001 |
knu |
Make test(1) a builtin command of our sh(1) for efficiency. The binary size increase is 3,784 bytes (about 0.6%).
I don't drop the printf builtin while I'm here because some /etc/rc.* scripts seem to use it before mounting /usr where printf(1) resides.
Reviewed by: arch (sheldonh) Inspired by: NetBSD, ksh Clued by: ume (on how the printf builtin is used)
|
86176 |
07-Nov-2001 |
tegge |
Don't call setvar() with the VTEXTFIXED flag. A copy is created by setvar() and passed to setvareq(). When the VTEXTFIXED flag is set, that copy is never freed, causing a memory leak.
PR: 31533 Submitted by: maxim@macomnet.ru
|
84936 |
14-Oct-2001 |
tegge |
Repair normally unused is_digit() macro.
|
84261 |
01-Oct-2001 |
obrien |
*** empty log message ***
|
83676 |
19-Sep-2001 |
tegge |
Don't check uninitialized memory for having the shell control character value CTLARI since this might break expansion of arithmetic expressions.
Don't access memory below start of stackblock.
Problem analyzed by hunt@iprg.nokia.com, slightly different patch applied.
PR: 24443 Submitted by: hunt@iprg.nokia.com
|
83675 |
19-Sep-2001 |
tegge |
BASESYNTAX, DQSYNTAX, SQSYNTAX and ARISYNTAX handles negative indexes. Allow those to be used to properly quote characters in the shell control character range.
|
83674 |
19-Sep-2001 |
tegge |
Adjust some type checks to include CTLQUOTEMARK in the range of shell control characters.
|
81602 |
13-Aug-2001 |
peter |
Initialize infp at main()
|
81586 |
13-Aug-2001 |
ru |
Removed duplicate VCS ID tags, as per style(9).
|
81298 |
08-Aug-2001 |
sheldonh |
can not -> cannot
|
81251 |
07-Aug-2001 |
ru |
mdoc(7) police:
Avoid using parenthesis enclosure macros (.Pq and .Po/.Pc) with plain text. Not only this slows down the mdoc(7) processing significantly, but it also has an undesired (in this case) effect of disabling hyphenation within the entire enclosed block.
|
80381 |
26-Jul-2001 |
sheldonh |
Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The definitions are more readable, and it's possible that they're more portable to pathalogical platforms.
Submitted by: David Hill <david@phobia.ms>
|
80196 |
23-Jul-2001 |
sheldonh |
Break the list of parameter expansions into two lists so that the paragraph introducing the prefix and suffix pattern expansions does not appear as part of the explanation for the string length expansion.
|
79754 |
15-Jul-2001 |
dd |
Remove whitespace at EOL.
|
79526 |
10-Jul-2001 |
ru |
mdoc(7) police: removed HISTORY info from the .Os call.
|
79366 |
06-Jul-2001 |
ru |
mdoc(7) police: sort SEE ALSO xrefs (sort -b -f +2 -3 +1 -2).
|
78806 |
26-Jun-2001 |
dwmalone |
Use the correct printf format to print a long.
Approved by: cracauer
|
78732 |
24-Jun-2001 |
dd |
Include missing header files which define functions for which gcc has builtins (e.g., exit, strcmp).
|
78686 |
24-Jun-2001 |
dd |
Remove duplicate words.
|
78469 |
19-Jun-2001 |
des |
Add more headers that are required with -fno-builtin (stdlib and strings)
|
77557 |
01-Jun-2001 |
gad |
Fix how /bin/sh handles 'for' and 'case' statements when it is called to do errexit (-e) processing. This solves a problem where 'make clean' would fail with an unspecified error in certain automake-generated makefiles.
Reviewed by: no objections from -hackers... MFC after: 2 weeks
|
77463 |
30-May-2001 |
imp |
Use PATH_MAX in preference in MAXPATHLEN.
|
76090 |
28-Apr-2001 |
dd |
Document "chdir" builtin.
|
75577 |
17-Apr-2001 |
kris |
-Wnon-const-format sweep: make format strings const char *'s, add __printflike()/__printf0like() to function prototypes, as appropriate.
Reviewed by: bde, -audit
|
75336 |
09-Apr-2001 |
brian |
``|'' should be more binding than ``!'' so that this isn't broken:
if ! echo bla | wc -c ; then echo broken fi
Obtained from: NetBSD
|
75160 |
04-Apr-2001 |
brian |
A much better (more correct) fix for handling ``!'' characters
Obtained from: NetBSD
|
75155 |
04-Apr-2001 |
brian |
Handle ``!'' characters when they appear as second and subsequent parts of an && or || expression.
This makes this expression work as expected:
if true && ! false; then echo yes; fi
|
72086 |
06-Feb-2001 |
cracauer |
Fix child's SIGSTOP behaviour in scripts.
When a child is receiving SIGSTOP, eval continues with the next command. While that is correct for the interactive case (Control-Z and you get the prompt back), it is wrong for a shellscript, which just continues with the next command, never again waiting for the stopped child. Noted when childs from cronjobs were stopped, just to make more processes (by wosch).
The fix is not to return from a job wait when the wait returned for a stopped child while in non-interactive mode. This bahaviour seems to be what bash2 and ksh implement. I tested for correct behaviour for finnaly killing the child with and without forgrounding it first. When not foregrouding before killing, the shell continues with the script, which is what the other shells do as well.
Reviewed by: Silence on -current
|
71895 |
01-Feb-2001 |
ru |
mdoc(7) police: split punctuation characters + misc fixes.
|
71097 |
16-Jan-2001 |
ru |
Prepare for mdoc(7)NG.
|
70150 |
18-Dec-2000 |
ru |
Prepare for mdoc(7)NG.
|
70056 |
15-Dec-2000 |
ru |
Prepare for mdoc(7)NG.
|
69793 |
09-Dec-2000 |
obrien |
Add `_PATH_DEVZERO'. Use _PATH_* where where possible.
|
69050 |
22-Nov-2000 |
ru |
mdoc(7) police: Er macro usage cleanup.
|
69029 |
22-Nov-2000 |
kris |
Use secure temporary filenames during build.
Audited by: markm, cracauer
|
66612 |
03-Oct-2000 |
brian |
Implement the <> redirection operator.
|
64705 |
16-Aug-2000 |
cracauer |
Disable part of my 8-bits fixes from December 1999.
Serious fix still needed, see discussion on -current (Subject: /bin/sh dumps core with here-document of 8bit text)
Problem in this code originally spotted by Jun Kuriyama <kuriyama@FreeBSD.org>
|
64704 |
16-Aug-2000 |
cracauer |
Fix type builtin for absolute paths and relative paths with directory names in them.
Also use a colon in the answer of `type` everytime the questioned item is not usable.
PR: bin/20567
|
64702 |
16-Aug-2000 |
cracauer |
From submitter: growstackblock() sometimes relocates a stack_block considered empty without properly relocating stack marks referencing that block. The first call to popstackmark() with the unrelocated stack mark as argument then causes sh to abort.
Relocating the relevant stack marks seems to solve this problem.
The patch changes the semantics of popstackmark() somewhat. It can only be called once after a call to setstackmark(), thus cmdloop() in main.c needs an extra call to setstackmark().
PR: bin/19983 Submitted by: Tor.Egge@fast.no Reviewed by: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at>
|
63799 |
24-Jul-2000 |
sheldonh |
Mark up the -a flag to unalias as a flag (Fl), not an argument (Ar).
|
63798 |
24-Jul-2000 |
sheldonh |
Add missing punctuation to one line.
|
63359 |
17-Jul-2000 |
marko |
Document the builtin echo command
Reviewed by: Matthew Hunt <mph@astro.caltech.edu>
|
63223 |
15-Jul-2000 |
sada |
Fixd with alias missing.
PR: bin/19475 Approved by: Martin Cracauer <cracauer@cons.org> (with conditions)
|
62137 |
26-Jun-2000 |
mph |
Add \a and \e to "echo -e" escape handling.
|
60593 |
15-May-2000 |
cracauer |
Fix parsing of string for eval command.
PR: 18447 Submitted by: Koji Mori <mori@tri.asanuma.co.jp>
|
60592 |
15-May-2000 |
cracauer |
Fix environment passung to eval'ed commands.
PR: bin/6577 Submitted by: Anatoly Vorobey <mellon@pobox.com> Approved by: silence amoung other sh experts
|
59438 |
20-Apr-2000 |
cracauer |
Rename the trace() function (that is build only in the -DDEBUG=2 case), so that it doesn't clash with the ncurses function of the same name when linking statically with -ltermcap.
The linker only complains when -static is used, and it is not clear whether this is a bug.
PR: bin/18104 Submitted by: Anatoly Vorobey <mellon@pobox.com>
|
59437 |
20-Apr-2000 |
cracauer |
Include <errno.h> when compiling with -DDEBUG=2
PR: bin/18104 Submitted by: mellon@pobox.com
|
59436 |
20-Apr-2000 |
cracauer |
Fix warnings, some of them serious because sh violated name 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.
|
59214 |
14-Apr-2000 |
imp |
Use #include <errno.h> rather than extern int errno;.
|
57225 |
15-Feb-2000 |
cracauer |
Fix ${#varname} (getting length of string) when in double-quotes.
Approved-by: jkh
PR: bin/12137 Submitted by: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
|
54884 |
20-Dec-1999 |
cracauer |
Fix command hash handling on PATH=... command
Noted by and fix works for Marcel Moolenaar <marcel@scc.nl>
|
54679 |
16-Dec-1999 |
cracauer |
Second part of 8-bit fixes.
|
54643 |
15-Dec-1999 |
cracauer |
Document ulimit -b for RLIMIT_SBSIZE.
|
54631 |
15-Dec-1999 |
cracauer |
First round of 8-bit fixes.
|
54145 |
05-Dec-1999 |
cracauer |
make '|' character visible.
PR: docs/15265 Submitted by: takamune@avrl.mei.co.jp
|
54132 |
04-Dec-1999 |
cracauer |
Fix "subscript has type `char'" warnings by casting to int, as discussed on -arch.
|
53891 |
29-Nov-1999 |
cracauer |
Include strerror(errno) in error messages after failed system calls. Fix a warning.
|
53349 |
18-Nov-1999 |
sheldonh |
Follow-up on mdoc fixes in rev 1.35; this includes things that I missed in that revision as well as things I broke in that revision. A note- worthy instance of the latter case was the inversion of -E and -V in the subsection on Commandline Editing.
|
53282 |
17-Nov-1999 |
cracauer |
The pipleline problem introduced in version 1.22 wasn't fully fixed in 1.23. This revision should work for long pipes both in here-documents/backquote and in normal cases.
Fix works for jmz, bde.
|
53081 |
10-Nov-1999 |
sheldonh |
Don't call bash(1) a Korn shell clone. Instead, use pdksh(1) as an example of such a clone.
PR: 14601 Submitted by: Matthias Buelow <mkb@altair.mayn.de>
|
52972 |
07-Nov-1999 |
steve |
Correct logic from previous commit - middle processes in long pipes don't have their stdin closed indisciminantly.
Reviewed by: markm
|
52900 |
05-Nov-1999 |
cracauer |
When a backquote command inside a here-document had a pipe with more than two processes (got that? :-), the stdin fd of the middle processes that has just been set up was accidetially closed. Don't do this.
PR: bin/14527
|
52526 |
26-Oct-1999 |
cracauer |
Fix ';' command when used with -e flag.
PR: bin/14509
|
52072 |
09-Oct-1999 |
green |
Implement ulimit -b for RLIMIT_SBSIZE.
|
51985 |
07-Oct-1999 |
sheldonh |
Mdoc cleanup, with a few grammar cleanups on the side.
Reviewed by: mpp
|
51275 |
14-Sep-1999 |
sheldonh |
Correct some hard sentence breaks. Only those surrounding the previous commit and those which cause ugly nroff output have been fixed, since the purpose of the style guideline which they contravene is to reduce the sizes of deltas.
Reported by: bde
|
51090 |
08-Sep-1999 |
sheldonh |
Improve shell documentation:
* Consistently misspell built-in as builtin.
* Add a builtin(1) manpage and create builtin(1) MLINKS for all shell builtin commands for which no standalone utility exists. These MLINKS replace those that were created for csh(1).
* Add appropriate xrefs for builtin(1) to the csh(1) and sh(1) manpages, as well as to the manpages of standalone utilities which are supported as shell builtin commands in at least one of the shells. In such manpages, explain that similar functionality may be provided as a shell builtin command.
* Improve sh(1)'s description of the cd builtin command. Csh(1) already describes it adequately. Replace the cd(1) manpage with a builtin(1) MLINKS link.
* Clean up some mdoc problems: use Xr instead of literal "foo(n)"; use Ic instead of Xr for shell builtin commands.
* Undo English contractions.
Reviewed by: mpp, rgrimes
|
50698 |
31-Aug-1999 |
sheldonh |
Revert to using .Xr for builtins. The cross-references don't work now, but that doesn't mean that they will never work.
Requested by: mpp, rgrimes
|
50648 |
30-Aug-1999 |
sheldonh |
Clean-up:
Fix grammar and spelling nits. Use .Dq and .Qq where appropriate. Divorce trailing punctuation from quoted elements. Use .Dq instead of .Xr for builtins. Remove trailing whitespace and blank lines.
PR: 13340
|
50471 |
27-Aug-1999 |
peter |
$Id$ -> $FreeBSD$
|
50394 |
26-Aug-1999 |
tg |
Make the behaviour of `read -e', ie. treating backslashes as special, the default. Add -r option for the read builtin to reverse this.
PR: 13274 Reviewed by: cpiazza, hoek, sheldonh
|
48896 |
19-Jul-1999 |
sheldonh |
Fix handling of the cd command inside evaluations. It was changing PWD, which it should not do.
PR: 12578 Reported by: Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> Submitted by: Niall Smart <niall@pobox.com>
|
46684 |
08-May-1999 |
kris |
Various spelling/formatting changes.
Submitted by: Philippe Charnier <charnier@xp11.frmug.org>
|
46073 |
25-Apr-1999 |
imp |
First set of fixes to keep egcs happy. These include {} around single statement if blocks[*] when the else could be ambiguous, not defaulting to int type and removal of some unused variables.
[*] This is explicitly allowed by style(9) when the single statement spans more than one line.
Reviewed by: obrien, chuckr
|
45916 |
21-Apr-1999 |
cracauer |
Next approach to make loops in interactive interruptable.
PR: bin/9173
|
45834 |
19-Apr-1999 |
max |
Typo fix.
|
45649 |
13-Apr-1999 |
cracauer |
Remove my temporary detection for PR 7059, Tor Egge fixed this bug.
PR: 7059
|
45644 |
13-Apr-1999 |
tegge |
During variable expansion, the internal representation of the expression might be relocated. Handle this case. PR: 7059
|
45621 |
12-Apr-1999 |
cracauer |
Fix typo in source-explaining comment.
|
45618 |
12-Apr-1999 |
cracauer |
Add a guarded abort() for the problem in PR bin/7059 (no fix so far, this is hairy).
Reformat this file to comply to style(9). It had mixed styles before.
PR: bin/7059
|
45514 |
09-Apr-1999 |
tegge |
When a variable expansion is enclosed in double quotes, the internal representation of the expression is quoted. Take care of this when doing pattern matching in conjunction with trimming.
#!/bin/sh c=d:e; echo "${c%:e}"
PR: NetBSD PR#7231 Noticed by: Havard Eidnes <Havard.Eidnes@runit.sintef.no>
|
45266 |
03-Apr-1999 |
cracauer |
In interactive shells, break loops to the topmost level when a child is killed by a signal.
(In non-interactive shells - that means a shellscript - the shell just exits, this was already working)
PR: bin/9173
|
45263 |
03-Apr-1999 |
cracauer |
Implement -a flag. A test shell script can be found at http://www.cons.org/cracauer/download/sh-interrupt/testsuite/test_export.sh The PR also had test cases the new version passes.
Fix typo in comment.
PR: bin/1030
|
45243 |
02-Apr-1999 |
cracauer |
-T was missing in the synopsis line.
Submitted by: BDE
|
45221 |
01-Apr-1999 |
cracauer |
The immediate execution of traps I introduced in September 1998 (to make /etc/rc interruptible in cases when programs hang with blocked signals) isn't standard enough.
It is now switched off by default and a new switch -T enables it.
You should update /etc/rc to the version I'm about to commit in a few minutes to keep it interruptible.
|
45202 |
31-Mar-1999 |
brian |
sh doesn't support <> redirections. PR: 7325
|
41916 |
18-Dec-1998 |
jkoshy |
Add references to test(1) and expr(1).
|
41844 |
16-Dec-1998 |
imp |
Free memory from setmode.
Obtained from: OpenBSD
|
41582 |
07-Dec-1998 |
bde |
Fixed warnx format errors in printf and csh, and snprintf format errors in sh, by using separate macros for the 1, 2 and 3-arg calls to warnx. (The 3-arg warnx macro in sh/bltin/bltin.h used to require bogus dummy args.)
|
41467 |
02-Dec-1998 |
billf |
Fix typo. "If the an entry" --> "If an entry"
PR: docs/8140 Submitted by: Sue Blake <sue@vedanix.welearn.com.au>
|
39137 |
13-Sep-1998 |
tegge |
Be more consistent with handling of quote mark control character. Don't output double-quotes inside variable expansion/arithmetic expansion region in here-documents. When leaving the arithmetic expansion syntax mode, adjust the dblquote flag according to previous syntax, in order to avoid splitting of quoted variables.
|
39056 |
10-Sep-1998 |
cracauer |
Narrow down conditions to break wait() to process traps. Improve comments.
|
39049 |
10-Sep-1998 |
cracauer |
Fix an inefficiency I introduced in my last commit. Include "expand.h" vom memalloc.c to pull function declartion into scope
|
38950 |
08-Sep-1998 |
cracauer |
If traps are set, they are now executed even when a signal-blocking foreground child is running. Formerly, traps were exceuted after the next child exit.
The enables the user to put a breaking wrapper around a blocking application: (trap 'echo trap ; exit 1' 2; ./pestyblocker; echo -n)
The "echo -n" after the child call is needed to prevent sh from optimizing the trap-executing shell away. I'm working on this.
|
38887 |
06-Sep-1998 |
tegge |
Better handling of word splitting. Don't record the same region multiple times when performing nested variable expansion, and preserve some quoting information in order to avoid removing apparently empty expansion result.
|
38886 |
06-Sep-1998 |
tegge |
Don't blindly eliminate `..' and the previous pathname component. PR: 2541 Obtained from: NetBSD
|
38536 |
25-Aug-1998 |
cracauer |
Improve bookkeeping of in_waitcmd and style fixes. Submitted by: Bruce Evans
|
38535 |
25-Aug-1998 |
cracauer |
Re-enable killing childs with SIGQUIT. Spotted by Bruce Evans.
|
38530 |
24-Aug-1998 |
cracauer |
Got two volatile sig_atomic_t and int mixed up. Spotted by Gary Palmer.
|
38521 |
24-Aug-1998 |
cracauer |
Do not exit on SIGINT in non-interactive shells, fixes PR 1206, 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
|
37968 |
30-Jul-1998 |
jkoshy |
Document behaviour of "-" and "--" on the command line.
PR: docs/5399
|
37456 |
07-Jul-1998 |
bde |
Added a `build-tools' target for internal tools.
Removed explicit dependencies of foo.o on foo.c. These were mainly placeholders for comments about missing dependencies of tools objects on headers. This problem needs to be handled more generally.
|
36150 |
18-May-1998 |
charnier |
Add rcsid. Spelling.
|
35783 |
06-May-1998 |
bde |
Backed out previous backout. Put y.tab.h back in SRCS.
|
35737 |
05-May-1998 |
bde |
Backed out previous commit. It was tested, but not for the case where a separate object tree doesn't exist. Crufty makefiles will have to put y.tab.h in SRCS so that we know not to create foo.h from foo.y.
|
35708 |
04-May-1998 |
bde |
Fixed races in `make -jN' using new yacc rules.
|
35675 |
04-May-1998 |
cracauer |
When calling a shell function, remember whether exit status is tested. This is needed for the '-e' option. See the PR for more details. PR: 6047 Reviewed by: PR submitter, silence on review request.
|
35465 |
26-Apr-1998 |
bde |
Backed out most of rev.1.19 (explicit dependencies of object files on generated headers). This is now handled generally in bsd.prog.mk.
|
33261 |
12-Feb-1998 |
jdp |
Explicitly describe the rules the shell uses to search for a file sourced by the "." command.
|
33142 |
06-Feb-1998 |
cracauer |
Back out my previous attempt to fix SIGINT/SIGTERM behaviour
|
33138 |
06-Feb-1998 |
cracauer |
Fix handling of SIGINT/SIGQUIT for foreground subprocesses. Most urgent need is when you run sh around a program that intentionally uses SIGQUIT/SIGINT for asynchronous events, i.e. $EDITOR started from system(2), like many mailers do. This fixes PR bin/1206 and possibly bin/4241.
The solution committed has been tested for a large number of possible cases (see recent discussion on cvs-committers). I completed a make world, made sure 'make world' is interruptable and used the changed /bin/sh as a login shell all day, including job control and using SIGQUIT-catching programs (to write this message :-).
PR: bin/1206 Reviewed by: discussion on cvs-commiters
|
32194 |
02-Jan-1998 |
steve |
Correct a bogon in an example.
PR: 5415 Submitted by: Sergei S. Laskavy <laskavy@pc759.cs.msu.su>
|
32066 |
29-Dec-1997 |
alex |
Added $Id$.
|
31666 |
10-Dec-1997 |
eivind |
Remove simultaneous include of <sys/param.h> and <sys/types.h>. Reorder includes to be alphabetical some places since I already was in here.
|
31128 |
12-Nov-1997 |
jdp |
Document the exit status for a command that was terminated by a signal.
|
31098 |
10-Nov-1997 |
bde |
Fixed some type and value mismatches. setsignal() returned a bogusly cast value that was always ignored. Rev.1.9 of trap.c made this more bogus by returning a semantically different value after calling siginterrupt(). Avoid these problems by not returning a value.
|
30969 |
05-Nov-1997 |
ache |
1) Fix longstanding bug: trap 'echo xxx' 1 2 3 15 read x is not interrupted by ^C (due to restartable read syscall) and must be interrupted per POSIX Worse case: read -t 5 x hangs forever after ^C pressed (supposed to timeout after 5 secs) Fixed by adding siginterrupt(signo, 1) after catch handler installed
2) Do not reinstall sighandler immediately after it is called, BSD do it for us
|
30113 |
05-Oct-1997 |
jkh |
Changes to support full make parallelism (-j<n>) in the world target. Reviewed by: <many different folks> Submitted by: Nickolay N. Dudorov" <nnd@nnd.itfs.nsk.su>
|
29983 |
29-Sep-1997 |
msmith |
Add the '-t timeout' option to the 'read' builtin. This allows the '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
|
29332 |
13-Sep-1997 |
wosch |
PR: docs/4449 The -c flag is not documented in the sh(1) manapge.
Submitted by: adrian@virginia.edu
|
28729 |
25-Aug-1997 |
bde |
Restored clobbered parts of rev.1.15 (build intermediate object files for tools).
|
28346 |
18-Aug-1997 |
steve |
Make all status values an integral type and use pid_t when referring to process IDs.
|
26747 |
19-Jun-1997 |
jkh |
Back out previous fix - this bug's got diplomatic immunity as a registered political issue.
|
26743 |
19-Jun-1997 |
jkh |
>Number: 3780 >Category: bin >Synopsis: WEXITSTATUS() may return nagative value, which causes sh to generate bad $?
PR: 3780 Submitted by: sanewo@ba2.so-net.or.jp
|
26488 |
06-Jun-1997 |
ache |
Now [^abc] means the same as [!abc] like bash and *csh already does
|
26104 |
24-May-1997 |
steve |
Make sh(1) less aware of the bit fields returned by wait by using the WIF* macros in sys/wait.h.
PR: bin/3668 Submitted by: dholland@eecs.harvard.edu
|
25960 |
21-May-1997 |
steve |
Remove y.tab.h from the beforedepend target. Also add a rule that shows the dependency of arith_lex.[co] on y.tab.h.
Suggested by: Bruce Evans <bde@zeta.org.au>
|
25906 |
19-May-1997 |
steve |
Add explicit y.tab.h rule so that 'make depend clean all' does not fail with an "don't know how to make y.tab.h" error.
|
25905 |
19-May-1997 |
steve |
Use the __unused attribute where warranted.
|
25903 |
19-May-1997 |
steve |
Miscellaneous sorting and addition of rules for object files that depend on generated headers.
Reviewed by: Bruce Evans <bde@zeta.org.au>
|
25529 |
07-May-1997 |
steve |
Revise the section that explains how to protect parts of an $ENV script from being executed in non-interactive mode.
Suggested and Reviewed by: Brian Somers <brian@freebsd.org>
|
25471 |
05-May-1997 |
steve |
Don't source $ENV unless this is an interactive shell.
|
25235 |
28-Apr-1997 |
steve |
Turn on the new type builtin.
|
25233 |
28-Apr-1997 |
steve |
Sync with NetBSD's revision 1.29 of this file.
Obtained from: NetBSD
|
25232 |
28-Apr-1997 |
steve |
Remove an extra semicolon and nuke register keyword usage.
|
25231 |
28-Apr-1997 |
steve |
Fix redirection of unopened file descriptors and nuke register keyword usage.
Obtained from: NetBSD
|
25230 |
28-Apr-1997 |
steve |
Revert changes from rev 1.16 to 1.17 for now. Closes PR 2879.
|
25229 |
28-Apr-1997 |
steve |
mdoc-ify and cleanup UNIMPLEMENTED messages. Closes PR 2880.
|
25228 |
28-Apr-1997 |
steve |
Reorder declarations slightly.
|
25227 |
28-Apr-1997 |
steve |
Avoid a possible NULL pointer dereference, nuke register usage, and remove an unnecessary reset.
Obtained from: NetBSD
|
25226 |
28-Apr-1997 |
steve |
Nuke register keyword usage, #if -> #ifdef, and avoid void * arithmetic.
Obtained from: NetBSD
|
25225 |
28-Apr-1997 |
steve |
Nuke register keyword usage, rename pread to preadfd, and open input files FD_CLOEXEC.
Obtained from: NetBSD
|
25224 |
28-Apr-1997 |
steve |
When NO_HISTORY is defined and the history command is used show an error message.
Inspired by: NetBSD
|
25223 |
28-Apr-1997 |
steve |
Add a type builtin and nuke register keyword usage.
Obtained from: NetBSD
|
25222 |
28-Apr-1997 |
steve |
Nuke register keyword usage and #if -> #ifdef.
Obtained from: NetBSD
|
25221 |
28-Apr-1997 |
steve |
Shamelessly pilfer most of NetBSD's Makefile so that the problem with 'make -j n' and no .depend file goes away. I think Bruce mentioned this somewhere on one of the mailing lists.
Obtained from: NetBSD
|
24348 |
28-Mar-1997 |
imp |
compare return value from getopt against -1 rather than EOF, per the final posix standard on the topic.
|
22988 |
22-Feb-1997 |
peter |
Revert $FreeBSD$ to $Id$
|
22777 |
16-Feb-1997 |
steve |
Fix a expansion bug that caused the result of `echo $((1 << 30))` to get truncated.
Submitted by: bde
|
21673 |
14-Jan-1997 |
jkh |
Make the long-awaited change from $Id$ to $FreeBSD$
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.
|
21352 |
06-Jan-1997 |
steve |
Fix a problem that caused some foreground pipelines to die with:
tcsetpgrp failed, errno=1
Discovered and Reviewed by: joerg
|
21301 |
04-Jan-1997 |
steve |
Make sh(1) think and be in the same place at the same time. This closes PR#2331: strange output of sh's pwd on symlinked directories.
|
20902 |
24-Dec-1996 |
steve |
With these changes sh(1)'s trap command should be POSIX-compliant, while remaining (becoming :) compatible with other popular shells. Specifically these changes include:
1) Implement 'trap -l' to get a list of valid signals names. This is useful if you wanted to do something like reset all signal handlers to there defaults values, in which case something like this will do the trick.
trap `trap -l`
2) Reformat the output of 'trap' so it can be saved and later eval'd to restore the saved settings.
3) Allow the use of signal names as well as signal numbers.
4) Fix trap handling of SIGCHLD so that commands like the following (albeit, contrived) won't cause sh(1) to recurse ad infinitum.
trap uname 0 20
5) Make variables static that are used only in trap.c.
6) Minor 'style(9) police' mods.
|
20887 |
23-Dec-1996 |
steve |
Oops, it needs little more caulk to get it right.
|
20886 |
23-Dec-1996 |
steve |
Apply a little dab of bit caulk to keep those beggars from leaking out.
Noticed by: bde
|
20848 |
23-Dec-1996 |
steve |
Don't use _POSIX_PATH_MAX to limit the size of the path, instead use 'getcwd(NULL, 0)' just as pwd(1) does.
Suggested by: bde
|
20774 |
21-Dec-1996 |
steve |
Make sh(1) a little braver in the face of adversity. sh(1) now handles the getpwd() init problem the same way as bash and ksh do. Also while I was in here, I cleaned up the format a little, removed some unnnecessary #if SYMLINKS cruft, and changed the pwd builtin to use getcwd(3) as Joerg suggested.
|
20746 |
21-Dec-1996 |
steve |
This doesn't change any behavior, but may be a slight optimization. (num-- > 0) --> (--num >= 0).
Obtained from: NetBSD
|
20744 |
21-Dec-1996 |
steve |
Remove extra #undef.
|
20742 |
21-Dec-1996 |
steve |
Fix a problem caused by finger failure on my part. The builtin getopts should now work as expected. This fix was in the NetBSD code that I was merging from but missed getting into FreeBSD's version because of 'drain bamage' on my part.
Submitted by: NetBSD, joerg
|
20425 |
14-Dec-1996 |
steve |
Merge in NetBSD mods and -Wall cleaning.
Obtained from: NetBSD, me
|
19683 |
12-Nov-1996 |
peter |
Back out rev 1.7 which was to fix PR#1206 (to be reopened).
This patch causes too many side effects, one of which bites hard is when interrupting a 'make fetch' in the ports tree (PR#1990). This whole area is a real can of worms....
This most definately should go into 2.2
Reviewed by: steve, bde
|
19281 |
31-Oct-1996 |
ache |
1) define STATIC as static and not empty 2) replace collate_range_cmp call with its code
|
19240 |
29-Oct-1996 |
steve |
Add the -p (privileged) commandline switch found in bash, zsh, and friends.
Reviewed by: joerg
|
19176 |
25-Oct-1996 |
bde |
Build intermediate object files for mkinit, mknodes and mksyntax so that simple regresssion tests based on `cmp' work. mkdep still doesn't work right for these tools. They should probably be in separate directories.
Sorted dependencies.
|
19084 |
22-Oct-1996 |
steve |
Close PR# 1206. sh(1) now ignores SIGINT and SIGQUIT when a child is forked and the -c commandline switch has been specified.
Reviewed by: joerg
|
18954 |
16-Oct-1996 |
steve |
Benign | --> || correction.
|
18754 |
06-Oct-1996 |
steve |
Fix a problem with sh that conflicts with the -e flag text in the man page. Now this will work correctly:
/bin/sh -ec 'false && true; echo hi'
Obtained from: VaX#n8 <vax@linkdead.paranoia.com>
|
18614 |
01-Oct-1996 |
peter |
re-activate the printf builtin now that src/usr.bin/printf.c has been tweaked to work as a builtin better (ie: calls the real printf formatting code, not sh's cut-down out1fmt() function)
|
18267 |
12-Sep-1996 |
adam |
Mend 'exit' without breaking 'exit 1' *blush* %-\
Pointed out by: bruce
|
18254 |
12-Sep-1996 |
bde |
Backed out last change. It broke even `exit 1'.
|
18202 |
10-Sep-1996 |
peter |
Ok, lets try this again, shall we? It was definatly my mistake, not Steve's.. :-]
|
18200 |
10-Sep-1996 |
peter |
ack! back these out so I can see what I did wrong. It looks like a patch-by-hand botch, but it sig-11's during make world.
|
18198 |
10-Sep-1996 |
peter |
Fix for PR#1248, sh doesn't expand past ${9}
Submitted by: Steve Price <sprice@hiwaay.net>
|
18154 |
08-Sep-1996 |
adam |
let the "exit" command return status when it is implicit
|
18019 |
03-Sep-1996 |
peter |
eek, how did that happen? I must have committed something left over from when I was experimenting looking for an alternate format. *blush*
|
18018 |
03-Sep-1996 |
peter |
Fix for PR#1287. This makes sh behave sensibly in case statements in the 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)
|
18016 |
03-Sep-1996 |
peter |
Misc cleanups and fixes from Bruce: - 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.
|
17988 |
01-Sep-1996 |
peter |
oops, I didn't mean for the unconditional DEBUG code to go in, it's been off in FreeBSD for some time. I realised this a few seconds after the commit started..
|
17987 |
01-Sep-1996 |
peter |
Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is a 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
|
17891 |
29-Aug-1996 |
wosch |
[HISTORY] command appeared in Version 1 AT&T UNIX Obtained from: A Quarter Century of UNIX, Peter H. Salus, page 41
|
17562 |
12-Aug-1996 |
ache |
Take out 0201-0207 range - those characters abused by sh
|
17557 |
12-Aug-1996 |
ache |
Convert to newly added collate compare function
|
17538 |
12-Aug-1996 |
ache |
Simplify expression
|
17525 |
11-Aug-1996 |
ache |
Localize it
|
16663 |
24-Jun-1996 |
jkh |
Bring in my changes for removing the pestilent obj links (unless you really want them) from /usr/src. This is the final version of the patches, incorporating the feedback I've received from -current.
|
16070 |
02-Jun-1996 |
phk |
Backup yacc changes.
|
16013 |
30-May-1996 |
phk |
Use new yacc rules. (I'm fixing the tree as fast as I can :-)
|
15921 |
27-May-1996 |
peter |
This commit was generated by cvs2svn to compensate for changes in r15920, which included commits to RCS files with non-trunk default branches.
|
13882 |
03-Feb-1996 |
joerg |
Fix the borokeness that crept in with rev 1.10 of parser.c, the sh didn't correctly start background jobs anymore. Strange that nobody was complaining...
Add a dummy target for `builtins' in the Makefile, to prevent it from attempting to build this file by compiling builtins.c. :-/
|
12845 |
14-Dec-1995 |
bde |
Restored formatting from the old printf/printf.c.
|
12733 |
10-Dec-1995 |
joerg |
The shell incorrectly gave & precedence over ;. This breaks the traditional behaviour, and it violates Posix.2.
Fixes PR # bin/880: /bin/sh incorrectly parse...
Fixes also an earlier problem report about the shell not evaluating loops correctly. (Not files via GNATS.)
Submitted by: nnd@itfs.nsk.su (Nickolay N. Dudorov)
|
12730 |
10-Dec-1995 |
joerg |
Move out some of the shell builtin bogosity from printf's source to sh's builtin/bltin.h.
|
12273 |
14-Nov-1995 |
peter |
A fix for the "cd -" coredump on a brand new /bin/sh. The problem was noticed on a NetBSD bugs mailing list but this is entirely my own work.
Inspired by: Scott Reynolds <scottr@plexus.com>, for NetBSD
|
12043 |
03-Nov-1995 |
peter |
Implement allowing 'set -v' in the middle of a script to work. This means that a script containing: echo 1 set -v echo 2 will now produce output, like it does on SYSV machines and other 'proper' /bin/sh implementations..
This is done by a slight restructure of the input processor allowing it to read chunks from the file at a time, but process the data by line from the chunk.
Obtained from: Christos Zoulas for NetBSD. <christos@deshaw.com>
|
11601 |
21-Oct-1995 |
joerg |
o rename ulimit -p into ulimit -u, so we are in agreement with bash
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
|
11571 |
19-Oct-1995 |
joerg |
Implement the "ulimit" builtin. This is the analogon to csh's "limit" 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.
|
11377 |
09-Oct-1995 |
joerg |
Fix my breakage of the $0 handling during $ENV processing.
Since the broken version went into 2.1, this fix should, too.
|
11113 |
01-Oct-1995 |
joerg |
Make the mkinit internal command issue an #undef for each #define, to avoid "duplicate definition" warnings.
|
11111 |
01-Oct-1995 |
joerg |
Posixize:
sh -c [-aCefinuvx] command_string [ command_name [argument ...] ] 1
4.56.3 Options
-c Read commands from the command_string operand. Set the value of special parameter 0 (see 3.5.2) from the value of the command_name operand and the positional parameters ($1, $2, etc.) in sequence from the remaining argument operands.
Pointed out by: Kaleb Keithly (kaleb@x.org)
|
10934 |
21-Sep-1995 |
bde |
Fix relocation of job table.
while { sleep 1 & wait; } do echo 1; done
corrupted the job table every 4th iteration.
|
10917 |
20-Sep-1995 |
dg |
Don't dereference a NULL pointer in the case of a null pipe. e.g.: ls |> foo.out
sh now behaves the same as it does under SunOS 4.x for this case.
|
10399 |
28-Aug-1995 |
joerg |
Sigh. This will become a never ending story. :-(
When comparing my recent parser change against the ash in 1.1.5.1, i found that a couple of other problems in the same area has been fixed there, but not in 2.2. Semicolons and EOF do also delimit words...
|
10354 |
27-Aug-1995 |
joerg |
Make the shell handle a null command in a &&/|| sequence correctly. The && and || tokens do also terminate a command, not only the newline.
While i was at it, disabled trace code by default, it served no good purpose since it required the use of a debugger anyway to be turned on. Instead, placed a hint in the Makefile on how to turn it on.
This makes the shell ~ 10 % faster and ~ 4 KB smaller. :)
Pointed out by: jan@physik.TU-Berlin.DE (Jan Riedinger)
|
10181 |
23-Aug-1995 |
pst |
Clean up compilation warnings.
|
10025 |
11-Aug-1995 |
joerg |
sh(1) incorrectly ignored an EOF condition when looking for the closing backquote in a `foo` substitution.
Discovered by: Martin Welk <mw@theatre.pandora.sax.de>
|
9974 |
06-Aug-1995 |
joerg |
Fix /bin/sh's broken handling of the builtin getopts(1). The options ``-ffoo'' and ``-f foo'' have been treated differently.
This has been in violation of Posix.2 (that deprecates -ffoo, but doesn't disallow it).
|
8855 |
30-May-1995 |
rgrimes |
Remove trailing whitespace.
Reviewed by: phk
|
8294 |
05-May-1995 |
adam |
typo there --> their
|
8289 |
05-May-1995 |
dg |
From "Philippe Charnier" <charnier@lirmm.fr>:
There is a bug in sh: the built in command "fc -l" generates a core dump (*NULL in not_fcnumber).
According to the sh manual page (fc -l [-nr] [first [last]]), fc -l is a correct sequence (in that case, values are defaulted to -16 and -1) but fails when first is not given.
|
7502 |
30-Mar-1995 |
phk |
Make build work, even if there is no obj subdir.
|
6804 |
01-Mar-1995 |
guido |
Fix the deletion of trailing newlines with backquote expansion. Reviewed by: Submitted by: Obtained from:
|
5507 |
11-Jan-1995 |
paul |
What I think is a more correct fix for the handling of backslashes inside backquotes. Reversed my previous fix.
|
5458 |
09-Jan-1995 |
paul |
Fix a bug with handling backslash escapes inside some quotes. Should solve our problems with edit-pr.
|
5234 |
26-Dec-1994 |
bde |
Obtained from: partly from 1.1.5
Convert "" to "." for "cd" and "cd ''". chdir("") is required to fail on POSIX systems.
|
4204 |
06-Nov-1994 |
pst |
Add end of line check so mkinit doesn't produce garbage if you have a MKINIT line that doesn't have a comment on it (we have at least two).
This mkinit program was written by someone who obviously doesn't believe in defensive programming. :-( There's a LOT of work that needs to be done on this thing. :-( :-( :-(
|
4192 |
06-Nov-1994 |
jkh |
Get this braindead, mongoloid shell look in /stand for pwd if it can't find it in /bin. This is something of a kludge, I know, but consider my limited alternatives: I can't make this an execvp() without making people scream that I introduced a failure point or slowed down pwd, and I can't make it an optional macro since crunch doesn't let you pass arbitrary command-line args to the build of one of its crunch-ees. This is the simplest, if not the nicest looking, solution I could come up with.
|
3286 |
02-Oct-1994 |
ache |
libcompat removed
|
3044 |
24-Sep-1994 |
dg |
Added $Id$
|
2760 |
14-Sep-1994 |
sef |
With '!' being made into a keyword (yech!), case cases didn't work properly. This should fix it (passed my test cases). Originally discovered with perl's Configure (well, in FreeBSD, I don't know how the NetBSD folks discovered it).
Reviewed by: sef Submitted by: jtc@cygnus.com Obtained from: NetBSD
|
2375 |
28-Aug-1994 |
bde |
Add dependencies on libraries to DPADD. Someday this should be done automagically. -lfoo has to be right to work, but ${LIBFO0} is too easy to forget or misspell; nothing checks it and it should be different for shared libraries.
|
2180 |
21-Aug-1994 |
bde |
Touch init.c after making it in case mkinit refused to touch it after not changing it. mkinit's attempted smartness about timestamps is mismatched with the makefile. init.o is compiled _twice_ the first time it is made...
|
2111 |
18-Aug-1994 |
dg |
Got rid of stupid warning message.
|
1633 |
30-May-1994 |
rgrimes |
Need ${LDFLAGS} one more place.
|
1625 |
29-May-1994 |
rgrimes |
Need to sue ${LDFLAGS} when building local binaries so they get built static if ${NOSHARED}==YES. This makes it easier to bootstrap a system.
|
1557 |
26-May-1994 |
rgrimes |
This commit was generated by cvs2svn to compensate for changes in r1556, which included commits to RCS files with non-trunk default branches.
|