summaryrefslogtreecommitdiffstats
path: root/bin/sh/expand.c
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2008-05-15 19:55:27 +0000
committerstefanf <stefanf@FreeBSD.org>2008-05-15 19:55:27 +0000
commit91768cb1d914b246d9d97ff8f0f3d5f818bc2e25 (patch)
treeba1d6fa9c2d5b214b9146ad3e13330e205bd76b6 /bin/sh/expand.c
parenta83fe39f55a7280bc3bdf3e078ac29c9ff845178 (diff)
downloadFreeBSD-src-91768cb1d914b246d9d97ff8f0f3d5f818bc2e25.zip
FreeBSD-src-91768cb1d914b246d9d97ff8f0f3d5f818bc2e25.tar.gz
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
Diffstat (limited to 'bin/sh/expand.c')
-rw-r--r--bin/sh/expand.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index 1bd7079..2f0b9fd 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -638,7 +638,13 @@ evalvar(char *p, int flag)
special = 1;
p = strchr(p, '=') + 1;
again: /* jump here after setting a variable with ${var=text} */
- if (special) {
+ if (varflags & VSLINENO) {
+ set = 1;
+ special = 0;
+ val = var;
+ p[-1] = '\0'; /* temporarily overwrite '=' to have \0
+ terminated string */
+ } else if (special) {
set = varisset(var, varflags & VSNUL);
val = NULL;
} else {
@@ -768,6 +774,7 @@ record:
default:
abort();
}
+ p[-1] = '='; /* recover overwritten '=' */
if (subtype != VSNORMAL) { /* skip to end of alternative */
int nesting = 1;
OpenPOWER on IntegriCloud