|
|||||||||||
|
Re: use of $$ versus $ in makefile and bash
From: Michael Marsh <michael.a.marsh(at)gmail.com>
Date: Wed Aug 29 2007 - 11:08:30 EDT
"$" is a special character to make, so in cases where you need make to pass an actual "$" to something else, you have to use the special variable "$$". > I have spent several hours searching through the documentation for In this case, "d" is a shell variable defined within a rule. The shell refers to it as "$d", but using "$d" in your makefile would cause make to look for one of its own variables named "d". "$$d" becomes a literal "$d" to make, which is then passed to sh. "$(addprefix ...)" is a make command, and "${SYMLINKDIR}" and "${SYMLINKTARGET}" are makefile variables, which will be expanded by make and passed to the shell as literals. > EXAMPLE 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The difference in this example is that find is being run, and its stdout returned as a string. The shell pattern is "$(command)", which is equivalent to "`command`". Again, since the "$" is relevant to the shell, not make, we have to use the special "$$". > EXAMPLE 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Hopefully this example is clearer now. > Also, in the third example, does the variable name "bn" have It's defined locally to the for loop (well, not *really* locally, but effectively). Any name that isn't already being used should be fine here. Not knowing what the context around that snippet is, I couldn't say if "bn" was chosen for some mnemonic reason. -- Michael A. Marsh http://www.umiacs.umd.edu/~mmarshhttp://mamarsh.blogspot.comhttp://36pints.blogspot.com -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.orgReceived on Wed Aug 29 11:09:43 2007 This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 03:13:52 EDT |
||||||||||
|
|||||||||||