I am attempting to handle an unexpected output from a command within a for loop. I am using a proprietary unzip utility (mfunzip), however when the utility encounters a corrupt file, it begins to echo out an endless "Fatal error in InputBit!" message.
I am attempting to capture the output and continue the loop onto the next file.
for FILE in $(ls); do
if [ -d "$FILE" ]; then
...
...
# without command output, it runs indefinitely
output=$(mfunzip $currentfile $extractdir)
# it never reaches here
echo $output
if [[ $output = *Fatal* ]]; then
continue
fi
fi
done
however it's not seem to be working as it blocks at the output=$(mfunzip ... ) ... I would assume it's outputting endlessly to $output. The other problem seems that the "Fatal error" may not appear immediately, but rather half-way through attempting to mfunzip the file.
Are there better ways of handling this type of output?