From owner-svn-src-head@FreeBSD.ORG Thu May 31 00:36:57 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 24E941065672; Thu, 31 May 2012 00:36:57 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1033C8FC0A; Thu, 31 May 2012 00:36:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4V0auhx094938; Thu, 31 May 2012 00:36:56 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4V0auQh094934; Thu, 31 May 2012 00:36:56 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201205310036.q4V0auQh094934@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 31 May 2012 00:36:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r236346 - head/usr.bin/make X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 31 May 2012 00:36:57 -0000 Author: obrien Date: Thu May 31 00:36:56 2012 New Revision: 236346 URL: http://svn.freebsd.org/changeset/base/236346 Log: Add "-V '${VAR}'" variable expansion from Portable Berkeley Make. Submitted by: Simon Gerraty Modified: head/usr.bin/make/make.1 head/usr.bin/make/var.c Modified: head/usr.bin/make/make.1 ============================================================================== --- head/usr.bin/make/make.1 Wed May 30 23:42:48 2012 (r236345) +++ head/usr.bin/make/make.1 Thu May 31 00:36:56 2012 (r236346) @@ -320,6 +320,11 @@ Do not build any targets. Multiple instances of this option may be specified; the variables will be printed one per line, with a blank line for each null or undefined variable. +If +.Ar variable +contains a +.Sq Ic $ +then the value will be expanded before printing. .It Fl v Be extra verbose. Print any extra information. Modified: head/usr.bin/make/var.c ============================================================================== --- head/usr.bin/make/var.c Wed May 30 23:42:48 2012 (r236345) +++ head/usr.bin/make/var.c Thu May 31 00:36:56 2012 (r236346) @@ -2593,7 +2593,7 @@ void Var_Print(Lst *vlist, Boolean expandVars) { LstNode *n; - const char *name; + char *name; LST_FOREACH(n, vlist) { name = Lst_Datum(n); @@ -2601,13 +2601,17 @@ Var_Print(Lst *vlist, Boolean expandVars char *value; char *v; - v = emalloc(strlen(name) + 1 + 3); - sprintf(v, "${%s}", name); - + if (*name == '$') { + v = name; + } else { + v = emalloc(strlen(name) + 1 + 3); + sprintf(v, "${%s}", name); + } value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE)); printf("%s\n", value); - free(v); + if (v != name) + free(v); free(value); } else { const char *value = Var_Value(name, VAR_GLOBAL);