Do not expand arguments with unquoted
$*
Use: "$@"
You probably want local HASH=...
and local DIRTY=
in there.Also, why mix the old style
`command ...`
and $(command ...)
expansion.