From owner-svn-src-head@FreeBSD.ORG Fri Dec 6 22:24:38 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8C07A9EE; Fri, 6 Dec 2013 22:24:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5E84616BD; Fri, 6 Dec 2013 22:24:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rB6MOcY5055464; Fri, 6 Dec 2013 22:24:38 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id rB6MOc7n055463; Fri, 6 Dec 2013 22:24:38 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201312062224.rB6MOc7n055463@svn.freebsd.org> From: Jilles Tjoelker Date: Fri, 6 Dec 2013 22:24:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r259047 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Dec 2013 22:24:38 -0000 Author: jilles Date: Fri Dec 6 22:24:37 2013 New Revision: 259047 URL: http://svnweb.freebsd.org/changeset/base/259047 Log: sh: Split set -x output into a separate function. Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Fri Dec 6 22:13:51 2013 (r259046) +++ head/bin/sh/eval.c Fri Dec 6 22:24:37 2013 (r259047) @@ -750,6 +750,45 @@ isdeclarationcmd(struct narg *arg) (have_command || !isfunc("local")))); } +static void +xtracecommand(struct arglist *varlist, struct arglist *arglist) +{ + struct strlist *sp; + char sep = 0; + const char *p, *ps4; + + ps4 = expandstr(ps4val()); + out2str(ps4 != NULL ? ps4 : ps4val()); + for (sp = varlist->list ; sp ; sp = sp->next) { + if (sep != 0) + out2c(' '); + p = strchr(sp->text, '='); + if (p != NULL) { + p++; + outbin(sp->text, p - sp->text, out2); + out2qstr(p); + } else + out2qstr(sp->text); + sep = ' '; + } + for (sp = arglist->list ; sp ; sp = sp->next) { + if (sep != 0) + out2c(' '); + /* Disambiguate command looking like assignment. */ + if (sp == arglist->list && + strchr(sp->text, '=') != NULL && + strchr(sp->text, '\'') == NULL) { + out2c('\''); + out2str(sp->text); + out2c('\''); + } else + out2qstr(sp->text); + sep = ' '; + } + out2c('\n'); + flushout(&errout); +} + /* * Check if a builtin can safely be executed in the same process, * even though it should be in a subshell (command substitution). @@ -847,40 +886,8 @@ evalcommand(union node *cmd, int flags, argv -= argc; /* Print the command if xflag is set. */ - if (xflag) { - char sep = 0; - const char *p, *ps4; - ps4 = expandstr(ps4val()); - out2str(ps4 != NULL ? ps4 : ps4val()); - for (sp = varlist.list ; sp ; sp = sp->next) { - if (sep != 0) - out2c(' '); - p = strchr(sp->text, '='); - if (p != NULL) { - p++; - outbin(sp->text, p - sp->text, out2); - out2qstr(p); - } else - out2qstr(sp->text); - sep = ' '; - } - for (sp = arglist.list ; sp ; sp = sp->next) { - if (sep != 0) - out2c(' '); - /* Disambiguate command looking like assignment. */ - if (sp == arglist.list && - strchr(sp->text, '=') != NULL && - strchr(sp->text, '\'') == NULL) { - out2c('\''); - out2str(sp->text); - out2c('\''); - } else - out2qstr(sp->text); - sep = ' '; - } - out2c('\n'); - flushout(&errout); - } + if (xflag) + xtracecommand(&varlist, &arglist); /* Now locate the command. */ if (argc == 0) {