bash: changed branch parsing function