YARN-1865. ShellScriptBuilder does not check for some error conditions. Contributed by Remus Rusanu.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1588693 13f79535-47bb-0310-9956-ffa450edef68