From nobody@FreeBSD.org  Mon Apr  9 00:52:04 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id F1DCB106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Apr 2012 00:52:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id DDF388FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Apr 2012 00:52:04 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q390q4MX036034
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 9 Apr 2012 00:52:04 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q390q4PA036033;
	Mon, 9 Apr 2012 00:52:04 GMT
	(envelope-from nobody)
Message-Id: <201204090052.q390q4PA036033@red.freebsd.org>
Date: Mon, 9 Apr 2012 00:52:04 GMT
From: Jim Pryor <dubiousjim@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: In sh, "local var=$(cat)" only reads one line
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         166771
>Category:       bin
>Synopsis:       sh(1): "local var=$(cat)" only reads one line
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jilles
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 09 01:00:34 UTC 2012
>Closed-Date:    Sun Jul 15 10:51:20 UTC 2012
>Last-Modified:  Sun Apr 13 21:50:00 UTC 2014
>Originator:     Jim Pryor
>Release:        9.0-PRELEASE
>Organization:
>Environment:
FreeBSD vaio.jimpryor.net 9.0-PRERELEASE FreeBSD 9.0-PRERELEASE #0: Tue Nov 29 02:45:33 EST 2011     root@vaio.jimpryor.net:/usr/obj/usr/src/sys/MINE  amd64
>Description:
I notice the following issue in FreeBSD's /bin/sh, here's the version line from the source:
 * $FreeBSD: src/bin/sh/shell.h,v 1.22.2.1 2011/09/23 00:51:37 kensmith Exp $

Inside a function, a statement of the form:

  local VAR=$(cat)

will only consume the first line of stdin.

The same problem also afflicts a recent build of dash on Linux, but not Busybox's implementation of ash.

Also reported here: <http://www.mail-archive.com/dash@vger.kernel.org/msg00679.html>.
>How-To-Repeat:
#!/bin/sh

test1() {
    local IN=$(cat)
    printf "test1 <%s>\n" "$IN"
}

test1a() {
    local IN
    IN=$(cat)
    printf "test1a <%s>\n" "$IN"
}

test2() {
    local IN="$(cat)"
    printf "test2 <%s>\n" "$IN"
}

test3() {
    IN=$(cat)
    printf "test3 <%s>\n" "$IN"
}

test4() {
    IN="$(cat)"
    printf "test4 <%s>\n" "$IN"
}


MSG=$(printf "abc\ndef\nghi")

printf "%s" "$MSG" | test1
printf "%s" "$MSG" | test1a
printf "%s" "$MSG" | test2
printf "%s" "$MSG" | test3
unset IN
printf "%s" "$MSG" | test4

# The weird bit only shows up in test1:
# IN will only be assigned the first line of stdin.

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jilles 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Mon Apr 9 02:25:45 UTC 2012 
Responsible-Changed-Why:  
over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166771 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/166771: commit references a PR
Date: Sun, 15 Jul 2012 10:19:59 +0000 (UTC)

 Author: jilles
 Date: Sun Jul 15 10:19:43 2012
 New Revision: 238468
 URL: http://svn.freebsd.org/changeset/base/238468
 
 Log:
   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
 
 Added:
   head/tools/regression/bin/sh/expansion/export2.0   (contents, props changed)
   head/tools/regression/bin/sh/expansion/export3.0   (contents, props changed)
   head/tools/regression/bin/sh/expansion/local1.0   (contents, props changed)
   head/tools/regression/bin/sh/expansion/local2.0   (contents, props changed)
   head/tools/regression/bin/sh/expansion/readonly1.0   (contents, props changed)
 Modified:
   head/bin/sh/eval.c
   head/bin/sh/exec.c
   head/bin/sh/exec.h
   head/bin/sh/sh.1
 
 Modified: head/bin/sh/eval.c
 ==============================================================================
 --- head/bin/sh/eval.c	Sun Jul 15 06:08:11 2012	(r238467)
 +++ head/bin/sh/eval.c	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -672,6 +672,52 @@ out:
  		result->fd, result->buf, result->nleft, result->jp));
  }
  
 +static int
 +mustexpandto(const char *argtext, const char *mask)
 +{
 +	for (;;) {
 +		if (*argtext == CTLQUOTEMARK || *argtext == CTLQUOTEEND) {
 +			argtext++;
 +			continue;
 +		}
 +		if (*argtext == CTLESC)
 +			argtext++;
 +		else if (BASESYNTAX[(int)*argtext] == CCTL)
 +			return (0);
 +		if (*argtext != *mask)
 +			return (0);
 +		if (*argtext == '\0')
 +			return (1);
 +		argtext++;
 +		mask++;
 +	}
 +}
 +
 +static int
 +isdeclarationcmd(struct narg *arg)
 +{
 +	int have_command = 0;
 +
 +	if (arg == NULL)
 +		return (0);
 +	while (mustexpandto(arg->text, "command")) {
 +		have_command = 1;
 +		arg = &arg->next->narg;
 +		if (arg == NULL)
 +			return (0);
 +		/*
 +		 * To also allow "command -p" and "command --" as part of
 +		 * a declaration command, add code here.
 +		 * We do not do this, as ksh does not do it either and it
 +		 * is not required by POSIX.
 +		 */
 +	}
 +	return (mustexpandto(arg->text, "export") ||
 +	    mustexpandto(arg->text, "readonly") ||
 +	    (mustexpandto(arg->text, "local") &&
 +		(have_command || !isfunc("local"))));
 +}
 +
  /*
   * Check if a builtin can safely be executed in the same process,
   * even though it should be in a subshell (command substitution).
 @@ -743,11 +789,12 @@ evalcommand(union node *cmd, int flags, 
  	exitstatus = 0;
  	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
  		if (varflag && isassignment(argp->narg.text)) {
 -			expandarg(argp, &varlist, EXP_VARTILDE);
 +			expandarg(argp, varflag == 1 ? &varlist : &arglist,
 +			    EXP_VARTILDE);
  			continue;
 -		}
 +		} else if (varflag == 1)
 +			varflag = isdeclarationcmd(&argp->narg) ? 2 : 0;
  		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
 -		varflag = 0;
  	}
  	*arglist.lastp = NULL;
  	*varlist.lastp = NULL;
 
 Modified: head/bin/sh/exec.c
 ==============================================================================
 --- head/bin/sh/exec.c	Sun Jul 15 06:08:11 2012	(r238467)
 +++ head/bin/sh/exec.c	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -648,6 +648,19 @@ unsetfunc(const char *name)
  	return (0);
  }
  
 +
 +/*
 + * Check if a function by a certain name exists.
 + */
 +int
 +isfunc(const char *name)
 +{
 +	struct tblentry *cmdp;
 +	cmdp = cmdlookup(name, 0);
 +	return (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION);
 +}
 +
 +
  /*
   * Shared code for the following builtin commands:
   *    type, command -v, command -V
 
 Modified: head/bin/sh/exec.h
 ==============================================================================
 --- head/bin/sh/exec.h	Sun Jul 15 06:08:11 2012	(r238467)
 +++ head/bin/sh/exec.h	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -72,5 +72,6 @@ void hashcd(void);
  void changepath(const char *);
  void defun(const char *, union node *);
  int unsetfunc(const char *);
 +int isfunc(const char *);
  int typecmd_impl(int, char **, int, const char *);
  void clearcmdentry(void);
 
 Modified: head/bin/sh/sh.1
 ==============================================================================
 --- head/bin/sh/sh.1	Sun Jul 15 06:08:11 2012	(r238467)
 +++ head/bin/sh/sh.1	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -32,7 +32,7 @@
  .\"	from: @(#)sh.1	8.6 (Berkeley) 5/4/95
  .\" $FreeBSD$
  .\"
 -.Dd November 5, 2011
 +.Dd July 15, 2012
  .Dt SH 1
  .Os
  .Sh NAME
 @@ -1164,6 +1164,20 @@ Assignments are expanded differently fro
  tilde expansion is also performed after the equals sign and after any colon
  and usernames are also terminated by colons,
  and field splitting and pathname expansion are not performed.
 +.Pp
 +This special expansion applies not only to assignments that form a simple
 +command by themselves or precede a command word,
 +but also to words passed to the
 +.Ic export ,
 +.Ic local
 +or
 +.Ic readonly
 +built-in commands that have this form.
 +For this, the builtin's name must be literal
 +(not the result of an expansion)
 +and may optionally be preceded by one or more literal instances of
 +.Ic command
 +without options.
  .Ss Positional Parameters
  A positional parameter is a parameter denoted by a number greater than zero.
  The shell sets these initially to the values of its command line
 
 Added: head/tools/regression/bin/sh/expansion/export2.0
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/bin/sh/expansion/export2.0	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -0,0 +1,24 @@
 +# $FreeBSD$
 +
 +w='@ @'
 +check() {
 +	[ "$v" = "$w" ] || echo "Expected $w got $v"
 +}
 +
 +export v=$w
 +check
 +
 +HOME=/known/value
 +check() {
 +	[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +}
 +
 +export v=~
 +check
 +
 +check() {
 +	[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +}
 +
 +export v=x:~
 +check
 
 Added: head/tools/regression/bin/sh/expansion/export3.0
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/bin/sh/expansion/export3.0	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -0,0 +1,30 @@
 +# $FreeBSD$
 +
 +w='@ @'
 +check() {
 +	[ "$v" = "$w" ] || echo "Expected $w got $v"
 +}
 +
 +command export v=$w
 +check
 +command command export v=$w
 +check
 +
 +HOME=/known/value
 +check() {
 +	[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +}
 +
 +command export v=~
 +check
 +command command export v=~
 +check
 +
 +check() {
 +	[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +}
 +
 +command export v=x:~
 +check
 +command command export v=x:~
 +check
 
 Added: head/tools/regression/bin/sh/expansion/local1.0
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/bin/sh/expansion/local1.0	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -0,0 +1,28 @@
 +# $FreeBSD$
 +
 +run_test() {
 +	w='@ @'
 +	check() {
 +		[ "$v" = "$w" ] || echo "Expected $w got $v"
 +	}
 +
 +	local v=$w
 +	check
 +
 +	HOME=/known/value
 +	check() {
 +		[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +	}
 +
 +	local v=~
 +	check
 +
 +	check() {
 +		[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +	}
 +
 +	local v=x:~
 +	check
 +}
 +
 +run_test
 
 Added: head/tools/regression/bin/sh/expansion/local2.0
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/bin/sh/expansion/local2.0	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -0,0 +1,34 @@
 +# $FreeBSD$
 +
 +run_test() {
 +	w='@ @'
 +	check() {
 +		[ "$v" = "$w" ] || echo "Expected $w got $v"
 +	}
 +
 +	command local v=$w
 +	check
 +	command command local v=$w
 +	check
 +
 +	HOME=/known/value
 +	check() {
 +		[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +	}
 +
 +	command local v=~
 +	check
 +	command command local v=~
 +	check
 +
 +	check() {
 +		[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +	}
 +
 +	command local v=x:~
 +	check
 +	command command local v=x:~
 +	check
 +}
 +
 +run_test
 
 Added: head/tools/regression/bin/sh/expansion/readonly1.0
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ head/tools/regression/bin/sh/expansion/readonly1.0	Sun Jul 15 10:19:43 2012	(r238468)
 @@ -0,0 +1,7 @@
 +# $FreeBSD$
 +
 +w='@ @'
 +
 +v=0 HOME=/known/value
 +readonly v=~:~/:$w
 +[ "$v" = "$HOME:$HOME/:$w" ] || echo "Expected $HOME/:$w got $v"
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: jilles 
State-Changed-When: Sun Jul 15 10:50:45 UTC 2012 
State-Changed-Why:  
Fixed in 10-current; no MFC planned. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=166771 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/166771: commit references a PR
Date: Sun, 13 Apr 2014 21:49:49 +0000 (UTC)

 Author: jilles
 Date: Sun Apr 13 21:49:44 2014
 New Revision: 264423
 URL: http://svnweb.freebsd.org/changeset/base/264423
 
 Log:
   MFC r238468: 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.
   
   As for the MFC, it is easy to depend on this feature inadvertently, and
   adding this fixes a regression from stable/8 that may be apparent in things
   like
     local x=${y+a @}.
   
   PR:		bin/166771
   Relnotes:	yes
 
 Added:
   stable/9/tools/regression/bin/sh/expansion/export2.0
      - copied unchanged from r238468, head/tools/regression/bin/sh/expansion/export2.0
   stable/9/tools/regression/bin/sh/expansion/export3.0
      - copied unchanged from r238468, head/tools/regression/bin/sh/expansion/export3.0
   stable/9/tools/regression/bin/sh/expansion/local1.0
      - copied unchanged from r238468, head/tools/regression/bin/sh/expansion/local1.0
   stable/9/tools/regression/bin/sh/expansion/local2.0
      - copied unchanged from r238468, head/tools/regression/bin/sh/expansion/local2.0
   stable/9/tools/regression/bin/sh/expansion/readonly1.0
      - copied unchanged from r238468, head/tools/regression/bin/sh/expansion/readonly1.0
 Modified:
   stable/9/bin/sh/eval.c
   stable/9/bin/sh/exec.c
   stable/9/bin/sh/exec.h
   stable/9/bin/sh/sh.1
 Directory Properties:
   stable/9/bin/sh/   (props changed)
   stable/9/tools/regression/bin/sh/   (props changed)
 
 Modified: stable/9/bin/sh/eval.c
 ==============================================================================
 --- stable/9/bin/sh/eval.c	Sun Apr 13 21:23:15 2014	(r264422)
 +++ stable/9/bin/sh/eval.c	Sun Apr 13 21:49:44 2014	(r264423)
 @@ -657,6 +657,52 @@ out:
  		result->fd, result->buf, result->nleft, result->jp));
  }
  
 +static int
 +mustexpandto(const char *argtext, const char *mask)
 +{
 +	for (;;) {
 +		if (*argtext == CTLQUOTEMARK || *argtext == CTLQUOTEEND) {
 +			argtext++;
 +			continue;
 +		}
 +		if (*argtext == CTLESC)
 +			argtext++;
 +		else if (BASESYNTAX[(int)*argtext] == CCTL)
 +			return (0);
 +		if (*argtext != *mask)
 +			return (0);
 +		if (*argtext == '\0')
 +			return (1);
 +		argtext++;
 +		mask++;
 +	}
 +}
 +
 +static int
 +isdeclarationcmd(struct narg *arg)
 +{
 +	int have_command = 0;
 +
 +	if (arg == NULL)
 +		return (0);
 +	while (mustexpandto(arg->text, "command")) {
 +		have_command = 1;
 +		arg = &arg->next->narg;
 +		if (arg == NULL)
 +			return (0);
 +		/*
 +		 * To also allow "command -p" and "command --" as part of
 +		 * a declaration command, add code here.
 +		 * We do not do this, as ksh does not do it either and it
 +		 * is not required by POSIX.
 +		 */
 +	}
 +	return (mustexpandto(arg->text, "export") ||
 +	    mustexpandto(arg->text, "readonly") ||
 +	    (mustexpandto(arg->text, "local") &&
 +		(have_command || !isfunc("local"))));
 +}
 +
  /*
   * Check if a builtin can safely be executed in the same process,
   * even though it should be in a subshell (command substitution).
 @@ -728,11 +774,12 @@ evalcommand(union node *cmd, int flags, 
  	exitstatus = 0;
  	for (argp = cmd->ncmd.args ; argp ; argp = argp->narg.next) {
  		if (varflag && isassignment(argp->narg.text)) {
 -			expandarg(argp, &varlist, EXP_VARTILDE);
 +			expandarg(argp, varflag == 1 ? &varlist : &arglist,
 +			    EXP_VARTILDE);
  			continue;
 -		}
 +		} else if (varflag == 1)
 +			varflag = isdeclarationcmd(&argp->narg) ? 2 : 0;
  		expandarg(argp, &arglist, EXP_FULL | EXP_TILDE);
 -		varflag = 0;
  	}
  	*arglist.lastp = NULL;
  	*varlist.lastp = NULL;
 
 Modified: stable/9/bin/sh/exec.c
 ==============================================================================
 --- stable/9/bin/sh/exec.c	Sun Apr 13 21:23:15 2014	(r264422)
 +++ stable/9/bin/sh/exec.c	Sun Apr 13 21:49:44 2014	(r264423)
 @@ -644,6 +644,19 @@ unsetfunc(const char *name)
  	return (0);
  }
  
 +
 +/*
 + * Check if a function by a certain name exists.
 + */
 +int
 +isfunc(const char *name)
 +{
 +	struct tblentry *cmdp;
 +	cmdp = cmdlookup(name, 0);
 +	return (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION);
 +}
 +
 +
  /*
   * Shared code for the following builtin commands:
   *    type, command -v, command -V
 
 Modified: stable/9/bin/sh/exec.h
 ==============================================================================
 --- stable/9/bin/sh/exec.h	Sun Apr 13 21:23:15 2014	(r264422)
 +++ stable/9/bin/sh/exec.h	Sun Apr 13 21:49:44 2014	(r264423)
 @@ -72,5 +72,6 @@ void hashcd(void);
  void changepath(const char *);
  void defun(const char *, union node *);
  int unsetfunc(const char *);
 +int isfunc(const char *);
  int typecmd_impl(int, char **, int, const char *);
  void clearcmdentry(void);
 
 Modified: stable/9/bin/sh/sh.1
 ==============================================================================
 --- stable/9/bin/sh/sh.1	Sun Apr 13 21:23:15 2014	(r264422)
 +++ stable/9/bin/sh/sh.1	Sun Apr 13 21:49:44 2014	(r264423)
 @@ -1171,6 +1171,20 @@ Assignments are expanded differently fro
  tilde expansion is also performed after the equals sign and after any colon
  and usernames are also terminated by colons,
  and field splitting and pathname expansion are not performed.
 +.Pp
 +This special expansion applies not only to assignments that form a simple
 +command by themselves or precede a command word,
 +but also to words passed to the
 +.Ic export ,
 +.Ic local
 +or
 +.Ic readonly
 +built-in commands that have this form.
 +For this, the builtin's name must be literal
 +(not the result of an expansion)
 +and may optionally be preceded by one or more literal instances of
 +.Ic command
 +without options.
  .Ss Positional Parameters
  A positional parameter is a parameter denoted by a number greater than zero.
  The shell sets these initially to the values of its command line
 
 Copied: stable/9/tools/regression/bin/sh/expansion/export2.0 (from r238468, head/tools/regression/bin/sh/expansion/export2.0)
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ stable/9/tools/regression/bin/sh/expansion/export2.0	Sun Apr 13 21:49:44 2014	(r264423, copy of r238468, head/tools/regression/bin/sh/expansion/export2.0)
 @@ -0,0 +1,24 @@
 +# $FreeBSD$
 +
 +w='@ @'
 +check() {
 +	[ "$v" = "$w" ] || echo "Expected $w got $v"
 +}
 +
 +export v=$w
 +check
 +
 +HOME=/known/value
 +check() {
 +	[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +}
 +
 +export v=~
 +check
 +
 +check() {
 +	[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +}
 +
 +export v=x:~
 +check
 
 Copied: stable/9/tools/regression/bin/sh/expansion/export3.0 (from r238468, head/tools/regression/bin/sh/expansion/export3.0)
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ stable/9/tools/regression/bin/sh/expansion/export3.0	Sun Apr 13 21:49:44 2014	(r264423, copy of r238468, head/tools/regression/bin/sh/expansion/export3.0)
 @@ -0,0 +1,30 @@
 +# $FreeBSD$
 +
 +w='@ @'
 +check() {
 +	[ "$v" = "$w" ] || echo "Expected $w got $v"
 +}
 +
 +command export v=$w
 +check
 +command command export v=$w
 +check
 +
 +HOME=/known/value
 +check() {
 +	[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +}
 +
 +command export v=~
 +check
 +command command export v=~
 +check
 +
 +check() {
 +	[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +}
 +
 +command export v=x:~
 +check
 +command command export v=x:~
 +check
 
 Copied: stable/9/tools/regression/bin/sh/expansion/local1.0 (from r238468, head/tools/regression/bin/sh/expansion/local1.0)
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ stable/9/tools/regression/bin/sh/expansion/local1.0	Sun Apr 13 21:49:44 2014	(r264423, copy of r238468, head/tools/regression/bin/sh/expansion/local1.0)
 @@ -0,0 +1,28 @@
 +# $FreeBSD$
 +
 +run_test() {
 +	w='@ @'
 +	check() {
 +		[ "$v" = "$w" ] || echo "Expected $w got $v"
 +	}
 +
 +	local v=$w
 +	check
 +
 +	HOME=/known/value
 +	check() {
 +		[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +	}
 +
 +	local v=~
 +	check
 +
 +	check() {
 +		[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +	}
 +
 +	local v=x:~
 +	check
 +}
 +
 +run_test
 
 Copied: stable/9/tools/regression/bin/sh/expansion/local2.0 (from r238468, head/tools/regression/bin/sh/expansion/local2.0)
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ stable/9/tools/regression/bin/sh/expansion/local2.0	Sun Apr 13 21:49:44 2014	(r264423, copy of r238468, head/tools/regression/bin/sh/expansion/local2.0)
 @@ -0,0 +1,34 @@
 +# $FreeBSD$
 +
 +run_test() {
 +	w='@ @'
 +	check() {
 +		[ "$v" = "$w" ] || echo "Expected $w got $v"
 +	}
 +
 +	command local v=$w
 +	check
 +	command command local v=$w
 +	check
 +
 +	HOME=/known/value
 +	check() {
 +		[ "$v" = ~ ] || echo "Expected $HOME got $v"
 +	}
 +
 +	command local v=~
 +	check
 +	command command local v=~
 +	check
 +
 +	check() {
 +		[ "$v" = "x:$HOME" ] || echo "Expected x:$HOME got $v"
 +	}
 +
 +	command local v=x:~
 +	check
 +	command command local v=x:~
 +	check
 +}
 +
 +run_test
 
 Copied: stable/9/tools/regression/bin/sh/expansion/readonly1.0 (from r238468, head/tools/regression/bin/sh/expansion/readonly1.0)
 ==============================================================================
 --- /dev/null	00:00:00 1970	(empty, because file is newly added)
 +++ stable/9/tools/regression/bin/sh/expansion/readonly1.0	Sun Apr 13 21:49:44 2014	(r264423, copy of r238468, head/tools/regression/bin/sh/expansion/readonly1.0)
 @@ -0,0 +1,7 @@
 +# $FreeBSD$
 +
 +w='@ @'
 +
 +v=0 HOME=/known/value
 +readonly v=~:~/:$w
 +[ "$v" = "$HOME:$HOME/:$w" ] || echo "Expected $HOME/:$w got $v"
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
