rewrite the hook in pure sh shell

the pure shell makes it a bit more readable,
but I do not expect you to merge it - it's just mine opinion