I wrote a script to generate makefiles...
And it works but not always
Here is some info output...
This shouldn't happen:
$ mage.sh -u *.c > Makefile
Makefile -> /tmp/.mage.sh.432.mak
1
new file: dlist.c
1
new file: filter.c
1
new file: getaline.c
1
new file: hash.c
1
new file: main.c
1
new file: memdbg.c
1
new file: parser.c
This is ok:
$ mage.sh -u *.c
Makefile -> /tmp/.mage.sh.1120.mak
0
old file: dlist.c
0
old file: filter.c
0
old file: getaline.c
0
old file: hash.c
0
old file: main.c
0
old file: memdbg.c
0
old file: parser.c
And this is the guilty part of script (I think):
UpdateNew () {
# updates include only cc stuff
for file in $(echo "$1" | sed 's/:/ /g') ; do
if [ ! -r "$file" ]; then
Warn "Could not open - '$file'"
continue
fi
if $(grep -q '^'${file%.*}'[$](OBJ):' "${tmp}.mak"); then
echo $? 1>&2
Notify "old file: $file"
old="$old$file:"
else
echo $? 1>&2
Notify "new file: $file"
new="$new$file:"
fi
done
MkDepend "$old"
EmitCC "$new"
}
Note that script works when not redirecting???
How should I fix this?
Thanks
Ooops, I just noticed that when not redirecting to Makefile (which is copied in the first place) everything works... Anyway can I fix this behavior?