package se.vidstige.jadb.managers;

public class Bash {
    public static String quote(String s) {
        // TODO: Should also check other whitespace
        if (!s.contains(" ")) {
            return s;
        }
        return "'" + s.replace("'", "'\\''") + "'";
    }
}

package se.vidstige.jadb.managers;

public class Bash {
    public static String quote(String s) {
        // Check that s contains no whitespace
        if (s.matches("\\S+")) {
            return s;
        }
        return "'" + s.replace("'", "'\\''") + "'";
    }
}

Check other whitespace characters, e.g. tabs
Check other whitespace characters, e.g. tabs
