Shell { static String bashQuote(String arg) { StringBuilder buffer = new StringBuilder(arg.length() + 2); buffer.append('\''); buffer.append(arg.replace("'", "'\\''")); buffer.append('\''); return buffer.toString(); } Shell();  Shell(long interval);  Shell(long interval, boolean redirectErrorStream); static boolean isJava7OrAbove(); static void checkWindowsCommandLineLength(String...commands); static String[] getGroupsCommand(); static String[] getGroupsForUserCommand(final String user); static String[] getUsersForNetgroupCommand(final String netgroup); static String[] getGetPermissionCommand(); static String[] getSetPermissionCommand(String perm, boolean recursive); static String[] getSetPermissionCommand(String perm, boolean recursive,
                                                 String file); static String[] getSetOwnerCommand(String owner); static String[] getSymlinkCommand(String target, String link); static String[] getReadlinkCommand(String link); static String[] getCheckProcessIsAliveCommand(String pid); static String[] getSignalKillCommand(int code, String pid); static String getEnvironmentVariableRegex(); static File appendScriptExtension(File parent, String basename); static String appendScriptExtension(String basename); static String[] getRunScriptCommand(File script); static final String getHadoopHome(); static final String getQualifiedBinPath(String executable); static final String getWinUtilsPath(); String getEnvironment(String env); Process getProcess(); int getExitCode(); boolean isTimedOut(); static String execCommand(String ... cmd); static String execCommand(Map<String, String> env, String[] cmd,
      long timeout); static String execCommand(Map<String,String> env, String ... cmd); static final Log LOG; static final int WINDOWS_MAX_SHELL_LENGHT; static final String USER_NAME_COMMAND; static final Object WindowsProcessLaunchLock; static final OSType osType; static final boolean WINDOWS; static final boolean SOLARIS; static final boolean MAC; static final boolean FREEBSD; static final boolean LINUX; static final boolean OTHER; static final boolean PPC_64; static final String SET_PERMISSION_COMMAND; static final String SET_OWNER_COMMAND; static final String SET_GROUP_COMMAND; static final String LINK_COMMAND; static final String READ_LINK_COMMAND; static final String WINUTILS; static final boolean isSetsidAvailable; static final String TOKEN_SEPARATOR_REGEX; }
@Test public void testBashQuote() { assertEquals("'foobar'", Shell.bashQuote("foobar")); assertEquals("'foo'\\''bar'", Shell.bashQuote("foo'bar")); assertEquals("''\\''foo'\\''bar'\\'''", Shell.bashQuote("'foo'bar'")); }