summaryrefslogtreecommitdiffstats
path: root/bin/sh/expand.h
Commit message (Collapse)AuthorAgeFilesLines
* sh: Perform pathname generation during the first expansion phases.jilles2015-12-311-1/+4
| | | | | | | | This avoids the need to add and remove CTLESC bytes if pathname generation will not be performed (set -f). Side effect: the order of operations is slightly different: pathname generation in ${$+* $(CMD)} will not see filesystem changes from CMD.
* sh: Avoid copying argv for simple commands.jilles2015-11-011-0/+1
| | | | | Add dummy entries before and after so arglist's array is directly usable as argv.
* sh: Make struct arglist an array instead of a linked list.jilles2015-10-111-8/+5
| | | | | | | | | | | This simplifies the code (e.g. allowing use of qsort(3) instead of a hand-rolled mergesort) and should have better cache properties. The waste of unused args arrays after resizes is approximately the same as the savings from getting rid of the next pointers. At the same time, remove a piece of global state and move some duplicated code into a function.
* sh: Remove EXP_REDIR.jilles2014-12-211-1/+0
| | | | | | | | | | EXP_REDIR was supposed to generate pathnames in redirection if exactly one file matches, as permitted but not required by POSIX in interactive mode. It is unlikely this will be implemented. No functional change is intended. MFC after: 1 week
* sh: Make expari() static.jilles2014-02-261-1/+0
|
* sh: Expand here documents in the current process.jilles2013-02-031-1/+0
| | | | | | | | | | | | | | | | | 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.
* sh: Make various functions static.jilles2012-01-011-1/+0
|
* sh: Fix duplicate prototypes for builtins.jilles2011-06-131-1/+0
| | | | | | 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.
* sh: Save/restore changed variables in optimized command substitution.jilles2011-06-121-1/+0
| | | | | | | | | | | 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.
* sh: Don't do optimized command substitution if expansions have side effects.jilles2010-12-281-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* sh: Do IFS splitting on word in ${v+word} and ${v-word}.jilles2010-10-291-0/+2
| | | | | | | | | | | | | | | | | 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)
* sh: Constify various strings.jilles2009-12-241-2/+2
| | | | | Most of this is adding const keywords, but setvar() in var.c had to be changed somewhat more.
* Remove clause 3 from the UCB licenses.markm2004-04-061-4/+0
| | | | OK'ed by: imp, core
* Add the "wordexp" shell built-in command which will be used to implementtjr2002-12-261-0/+1
| | | | the POSIX wordexp() function.
* o __P has been reovedimp2002-02-021-6/+6
| | | | | | | | | | | | | | | | | | 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) { ...
* $Id$ -> $FreeBSD$peter1999-08-271-1/+1
|
* When a variable expansion is enclosed in double quotes, the internaltegge1999-04-091-2/+2
| | | | | | | | | | | 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>
* Be more consistent with handling of quote mark control character.tegge1998-09-131-3/+1
| | | | | | | 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.
* Better handling of word splitting. Don't record the same regiontegge1998-09-061-1/+3
| | | | | | multiple times when performing nested variable expansion, and preserve some quoting information in order to avoid removing apparently empty expansion result.
* Revert $FreeBSD$ to $Id$peter1997-02-221-1/+1
|
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Merge of 4.4-Lite2 sh source, plus some gcc -Wall cleaning. This is apeter1996-09-011-15/+8
| | | | | | | | | | | | | | 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
* Added $Id$dg1994-09-241-0/+1
|
* BSD 4.4 Lite bin Sourcesrgrimes1994-05-261-0/+73
OpenPOWER on IntegriCloud