Harden shell commands

Also improve/add MacOS readlink compatibility.

Change-Id: I9d78e8a271b85b6810d307b6ed0072c1ec13bfa6
2 files changed