Author: jilles Date: Fri Jun 17 10:21:24 2011 New Revision: 223183 URL: http://svn.freebsd.org/changeset/base/223183
Log: sh: Skip variables with invalid names in "set", "export -p", "readonly -p". This ensures the output of these commands is valid shell input. Added: head/tools/regression/bin/sh/builtins/export1.0 (contents, props changed) head/tools/regression/bin/sh/builtins/set2.0 (contents, props changed) Modified: head/bin/sh/var.c Modified: head/bin/sh/var.c ============================================================================== --- head/bin/sh/var.c Fri Jun 17 07:30:56 2011 (r223182) +++ head/bin/sh/var.c Fri Jun 17 10:21:24 2011 (r223183) @@ -612,6 +612,12 @@ showvarscmd(int argc __unused, char **ar qsort(vars, n, sizeof(*vars), var_compare); for (i = 0; i < n; i++) { + /* + * Skip improper variable names so the output remains usable as + * shell input. + */ + if (!isassignment(vars[i])) + continue; s = strchr(vars[i], '='); s++; outbin(vars[i], s - vars[i], out1); @@ -683,6 +689,13 @@ exportcmd(int argc, char **argv) for (vp = *vpp ; vp ; vp = vp->next) { if (vp->flags & flag) { if (values) { + /* + * Skip improper variable names + * so the output remains usable + * as shell input. + */ + if (!isassignment(vp->text)) + continue; out1str(cmdname); out1c(' '); } Added: head/tools/regression/bin/sh/builtins/export1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/export1.0 Fri Jun 17 10:21:24 2011 (r223183) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +env @badness=1 ${SH} -c 'v=`export -p`; eval "$v"' Added: head/tools/regression/bin/sh/builtins/set2.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/builtins/set2.0 Fri Jun 17 10:21:24 2011 (r223183) @@ -0,0 +1,3 @@ +# $FreeBSD$ + +! env @badness=1 ${SH} -c 'v=`set`; eval "$v"' 2>&1 | grep @badness _______________________________________________ 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-unsubscr...@freebsd.org"