]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
sh: Do IFS splitting on word in ${v+word} and ${v-word}.
authorjilles <jilles@FreeBSD.org>
Fri, 29 Oct 2010 13:42:18 +0000 (13:42 +0000)
committerjilles <jilles@FreeBSD.org>
Fri, 29 Oct 2010 13:42:18 +0000 (13:42 +0000)
commit28ad180ab428c06679f4d2e8422bfb77ae2a926c
treea904801ee278e1d897c3118d8e675fd52f1a7856
parentb6cd17990d125d91ed9a1a32e708c186c2fd3945
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)
bin/sh/expand.c
bin/sh/expand.h
bin/sh/mksyntax.c
bin/sh/parser.c
bin/sh/parser.h
tools/regression/bin/sh/expansion/plus-minus6.0 [new file with mode: 0644]