Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
leetow2003
Member
Posts: 70 Joined: Fri Nov 19, 2010 6:54 pm
Post
by leetow2003 » Tue Mar 05, 2013 3:04 am
I read a Makefile,look:
Code: Select all
dep:
(for i in init/*.c;do echo -n "init/";gcc -M $$i;done) >> tmp_make
cp tmp_make Makefile
if I write a shell script using the same codes,I find the $$i must be replaced
by $i,why?I want to know what the $$ means?
Combuster
Member
Posts: 9301 Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:
Post
by Combuster » Tue Mar 05, 2013 3:25 am
What does $ mean to make?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[
My OS ] [
VDisk/SFS ]
iansjack
Member
Posts: 4711 Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK
Post
by iansjack » Tue Mar 05, 2013 3:32 am
In this instance, do you want the command interpreter to see the value of $i, or do you want it to see "$i"?
kohlrak
Posts: 18 Joined: Mon Mar 04, 2013 1:54 am
Post
by kohlrak » Tue Mar 05, 2013 6:38 pm
leetow2003 wrote: I read a Makefile,look:
Code: Select all
dep:
(for i in init/*.c;do echo -n "init/";gcc -M $$i;done) >> tmp_make
cp tmp_make Makefile
if I write a shell script using the same codes,I find the $$i must be replaced
by $i,why?I want to know what the $$ means?
I'm not 100% sure, but it could be that $$ is a makefile escape for $, while in shells $$ represents the process ID.