Original Post
I'm having a problem and I can't find my error. It's driving me nuts!! Please help me, the details are as follows: I have a file named: sourcelist.tmp Its contents are a list of files I want to do stuff to, separated by spaces (no newlines). Below is an example of this file (The list is automatically generated so the directory trees look a little weird, but they're fine):
../Sources/Font/Test/../Letter.cpp ../Sources/Font/Test/../../Fileable/Fileable.cpp
And then I have a BASH script that processes these files. However, I'm having trouble with a case loop in it. Below is an excerpt of the trouble section:
# This variable indicates the files that have been processed so far
SOURCES="../Sources/Font/Test/LetterTest.cpp"
# This variable will be 1 until all files in sourcelist.tmp have been processed
LOOP=1
# This loop repeats until LOOP is null (once all files have been processed)
while [ ${LOOP} ]; do # Go through each file...
for SOURCE in `cat sourcelist.tmp`; do
# The following commented lines are not part of the script, but I use
# them to test that the case loop is finding SOURCE when it is in SOURCES
# and selecting that case, which it is not (my current problem):
# SOURCES="$${SOURCES}|$${SOURCE}"
# echo $${SOURCE};
# echo $${SOURCES};
case ${SOURCE} in
# If the file is listed in SOURCES, then it has already been processed,
# so LOOP is set to null and we check the next file... or end the while
# loop if this is the last file (*** THIS NEVER HAPPENS!!! WHY??? ***)
(${SOURCES}) LOOP="";;
# File is not in SOURCES so we add it to SOURCES...
(*) SOURCES="$${SOURCES}|$${SOURCE}"
# and process it...
if [ -e $${SOURCE} ]; then
# I do my stuff to file and sourcelist.tmp here
fi
# Make sure LOOP is 1 as we must continue while loop
LOOP=1
# Start new iteration of while loop (we want to start the for
# loop over since sourelist.tmp may have changed)
continue 2;;
esac
done
done
If you help me you will be my official hero of the week! Thanks, Beau