Enum Class ShellUtils.Shell
- All Implemented Interfaces:
Serializable,Comparable<ShellUtils.Shell>,Constable
- Enclosing class:
ShellUtils
This determines how arguments are quoted and/or escaped. This should be set based on the shell that is going to receive the actual commands, which may or may not be the local shell. In many cases, it is the local shell, but please ensure for remote cases, the correct shell is specified.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsChangeEnum ConstantDescriptionFor display purposes only.Unix shells that follow the same conventions as "sh".Plain Windows command-line arguments for the C runtimeThe Windows cmd.exe shell. -
Field Summary
Fields -
Method Summary
ChangeModifier and TypeMethodDescriptionstatic ShellUtils.ShellforOs(OperatingSystem os) Get the probable shell for the given operating systemabstract StringEscape and/or quote a single command-line argumentstatic ShellUtils.ShellReturns the enum constant of this class with the specified name.static ShellUtils.Shell[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DISPLAY
For display purposes only. DO NOT pass to any actual shell. -
UNIX_SH
Unix shells that follow the same conventions as "sh". This is most Unix shells. -
WINDOWS
Plain Windows command-line arguments for the C runtime- See Also:
-
WINDOWS_CMD
The Windows cmd.exe shell.NOTE: It seems to me using this with
ShellUtils.generateLine(List, Shell)is futile, if the intent is to use specific argument numbers in the batch file, e.g.,%1. If you make clear certain constraints to the user, maybe it's suitable, but especially involving quotes, it's not possible to encode any arbitrary string. It seems the cmd shell is primarily concerned with just passing the arguments along to child processes, as encoded, and then the child figures out the parsing. That said, if the child process parses to argc/argv, then so long as the full command line is passed through the batch file, it should work as intended. However, if grabbing individual arguments, they cannot be reliably controlled.LATER: There may be a way to factor the escaping part separately from the argument catenation part, so that special logic can be applied here to better guarantee argument numbering, but then there's still the issue if the final target is expected to parse to argc/argv, if that can be encoded reliably.
-
-
Field Details
-
LOCAL
The local shell, probably
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
forOs
Get the probable shell for the given operating system- Parameters:
os- the operating system- Returns:
- the shell, probably
-
generateArgument
Escape and/or quote a single command-line argument- Parameters:
a- the argument- Returns:
- the argument formed in such a way that the shell will interpret it as the given string in one argument
-