I need to retain the value of TEMP_FLAG
after my while loop ends.
#!/bin/bash
TEMP_FLAG=false
# loop over git log and set variable
git log --pretty="%H|%s" --skip=1 |
while read commit; do
# do stuff like parsing the commit...
# set variable
TEMP_FLAG=true
done
echo "$TEMP_FLAG" # <--- evaluates to false :(
I know that my issue is caused by piping the git log
to the while loop, which spawns a subshell that doesn't give back my updated variable.
However, is there a way get my intended behavior without changing the pipe?