Um die aktuellen Entry-Targets (all, clean, mrproper, test sind trivial) in GNU-Makefiles zu finden, muss man selbige erst lesen und dann auch noch verstehen. Benutzerfreundlicher gehts mit make help.
Das Help-Kommando für das Makefile wird in einer Variable gespeichert und sieht dann wie folgt aus:
HELP= @grep -B1 '^[a-zA-Z][^:]*:' Makefile |\ awk 'function p(h,t){printf"%-12s=%s\n",h,t};\ /\#+/{t=$$0};\ /:/{gsub(":.*","");h=$$0};\ /--/{p(h,t);t=h="";};\ END{p(h,t)}' |\ sed -n 's/=.*\#+/:/gp'Der Hilfecontext wird so erzeugt:
#+ build the complete project all: $(BUILD) #+ cleans all object files clean: $(CLEAN) #+ revirginize the directory, all configs are lost distclean: clean $(DISTCLEAN) #+ print this screen help: $(HELP) # more stuff which is not a legal entry love: @echo "make $@ - not war!"Als Ergebnis erhält man dann:
all : build the complete project clean : cleans all object files distclean : revirginize the directory, all configs are lost help : print this screen
Hin und wieder benötigt man eine Art Tagebuch, sei es zur ungefähren Stundenabrechnung in der Firma oder aber auch zur Protokollierung von Telefonanrufen.
Mit dem Tool today.sh wird ein einfaches Textfile erzeugt, mit dem man ein Tagebuch der Art:
$>cat today.log -- 08.07.2004 : - Praesentation in Powerpoint erstellt - Meeting besucht; Highscore bei www.wagenschenke.ch: 120m - Schreibtisch aufgeräumt, Kaffee gekocht, Blumen gegossen -- 09.07.2004 : - Quelltext dokumentiert - 3 Bugs gefixt
Das Shell-Script sieht so aus:
#------------------------------------------------------- # today.sh - poor mans diary script # # usage: # today.sh [logfile] # # generate a date string and append it to the given # logfile, afterwards the logfile is opened in the # editor at the line with the current date # #------------------------------------------------------- # init variables file=today.log datestr=$(date +"-- %d.%m.%Y") # command line processing if [ "$1" != "" ]; then file=$1; fi # init logfile test -f $file || touch $file grep -- "$datestr" $file > /dev/null || echo "$datestr" >> $file # search todays line and open editor at it line=$(grep -n -- "$datestr" $file | sed 's/:.*//g') let line++ $EDITOR +$line $file