Make a git repository read-only over ssh depending on the key used
Should be

printf "%s\n" "$2" | grep -E "^git-upload-pack" &amp;&amp; sh -c "$2"


Notes:


sh not bash for portability
The printf instead of echo is for safety.  What happens if someone puts  "-n foo" as "$2"?