![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
Bash scirpt help (msys)?
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? |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
And here is some more "funny" stuff...
Bash debug output: $ cp copy Makefile $ mage.sh -u *.c > new Makefile -> /tmp/_mage.sh.1144.mak ++ grep -q '^dlist[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 0 0 + set +o xtrace old file: dlist.c ++ grep -q '^filter[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 0 0 + set +o xtrace old file: filter.c ++ grep -q '^getaline[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 0 0 + set +o xtrace old file: getaline.c ++ grep -q '^hash[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 1 1 + set +o xtrace new file: hash.c ++ grep -q '^main[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 0 0 + set +o xtrace old file: main.c ++ grep -q '^memdbg[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 0 0 + set +o xtrace old file: memdbg.c ++ grep -q '^parser[$](OBJ):' /tmp/_mage.sh.1144.mak + echo 0 0 + set +o xtrace old file: parser.c $ cp copy Makefile $ mage.sh -u *.c > Makefile Makefile -> /tmp/_mage.sh.996.mak ++ grep -q '^dlist[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: dlist.c ++ grep -q '^filter[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: filter.c ++ grep -q '^getaline[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: getaline.c ++ grep -q '^hash[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: hash.c ++ grep -q '^main[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: main.c ++ grep -q '^memdbg[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: memdbg.c ++ grep -q '^parser[$](OBJ):' /tmp/_mage.sh.996.mak + echo 1 1 + set +o xtrace new file: parser.c I have put script in the attachment. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2006
Posts: 36
Rep Power: 0
![]() |
I figured it out...
Makefile gets truncated if redirected to it before script is run (and Makefile copied)... Bye |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how do I call a bash script in C? | smile_sunshine | C | 8 | Apr 30th, 2006 10:36 PM |
| Bash or Perl? | titaniumdecoy | Other Scripting Languages | 9 | Jan 30th, 2006 5:42 PM |
| Do you use perl over bash scripting? | linuxpimp20 | Perl | 3 | Sep 12th, 2005 3:29 PM |
| Window Re-sizing in bash script. | Huck | Bash / Shell Scripting | 1 | May 1st, 2005 6:31 PM |