Subject: Re: How to properly use shell commands that are defined in make(1)
To: Todd Vierling <tv@duh.org>
From: Roland Illig <rillig@NetBSD.org>
List: tech-pkg
Date: 11/24/2005 22:38:50
Todd Vierling wrote:
> On Thu, 24 Nov 2005, Roland Illig wrote:
> 
> 
>>Quite a few shell programs in pkgsrc use commands similar to how they are used
>>in the pkgsrc Makefiles. As it were much better if the tools were used not
>>only similar but _equal_ to inside Makefiles, I've written a quiet little, but
>>useful make(1) target:
> 
> 
> Why not use show-vars-eval?  make(1) uses ${FOO} form, and if you use
> show-vars-eval, a shell script can also use ${FOO} form for exactly thye
> same result.

$ make show-vars-eval VARS=PKG_INFO PKGTOOLS_ENV=foo="\"bar baz\""
PKG_INFO=foo="bar\ baz"\ /home/roland/pkg/sbin/pkg_info\ -K\ 
/home/roland/pkg/var/db/pkg
$ eval `make show-vars-eval VARS=PKG_INFO PKGTOOLS_ENV=foo="\"bar baz\""`
$ $PKG_INFO mc
bash: foo=bar\: command not found

I know the details are only subtle, but they exist.

In general, I think functions more often do what you expect than shell 
variables. There are always white-space issues when they are used 
unquotedly. Not to mention what happens to * and \.

Roland