Write Only Code

9 PM January 21, 2004

This line of code took me half an hour to write and test. (Broken into multiple lines for readability.)

echo \\t-ps -ef '|' 
   awk \'$$''$$\1 = \"$${LOGNAME}\"
        \&\& /`basename $${exe}`/ \&\& !/awk/ 
            {print $$''$$\2}\' '|'
   xargs -n 1 kill -9 >> ${MAKE_DEPEND}; 

This code is part of a makefile action that outputs a makefile rule. This particular line causes the output rule to kill a running executable, prior to linking it. I wrote it because I was sick of getting 'Text file busy' errors, and having to restart the make.

I am particularly proud of the $$''$$ bit. That is how to output two consecutive dollar signs into the generated make rule. $$$$ must be some kind of reserved symbol in our ancient version of make, because it causes a five digit number to be output.

By alang | # | Comments (2)
(Posted to Software Development)
© 2003-2006 Alan Green