I had a similar problem to this with Python using readlines() but I’m not sure if it’s the same here.
The read command is hanging my bash script.
generate_email()
{
# --- Arguments
oldrev=$(git rev-parse $1)
newrev=$(git rev-parse $2)
refname="$3"
# ... some code ...
}
# ... more code ...
while read oldrev newrev refname
do
generate_email $oldrev $newrev $refname
done
Any ideas on how to fix this?
You’re not telling read to read from anything. So it’s just waiting for input from
stdin.If you’re wanting to read from a file, you need to use
readlike so:Note the
< /path/to/file. That’s where you’re actually telling read to read from the file.If you’re wanting to read from an input stream, you can use
while readlike so: