Class Shell
java.lang.Object
org.codehaus.plexus.util.cli.shell.Shell
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BourneShell
,CmdShell
,CommandShell
Class that abstracts the Shell functionality, with subclasses for shells that behave particularly, like
command.com
cmd.exe
- Since:
- 1.2
- Author:
- Carlos Sanchez
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addShellArg
(String arg) void
clone()
protected String
protected char
getCommandLine
(String executable, String[] arguments) Get the command line for the provided executable and arguments in this shellprotected char[]
getEscapeChars
(boolean includeSingleQuote, boolean includeDoubleQuote) protected char
protected String
getOriginalCommandLine
(String executable, String[] arguments) protected char[]
getRawCommandLine
(String executable, String[] arguments) String[]
Get the command to execute the shellgetShellCommandLine
(String[] arguments) Get the full command line to execute, including shell command, shell arguments, executable and executable argumentsprotected boolean
protected boolean
boolean
boolean
protected boolean
protected boolean
protected String
quoteOneItem
(String inputString, boolean isExecutable) protected void
setArgumentEscapePattern
(String argumentEscapePattern) protected void
setArgumentQuoteDelimiter
(char argQuoteDelimiter) protected void
setDoubleQuotedArgumentEscaped
(boolean doubleQuotedArgumentEscaped) protected void
setDoubleQuotedExecutableEscaped
(boolean doubleQuotedExecutableEscaped) void
setExecutable
(String executable) protected void
setExecutableQuoteDelimiter
(char exeQuoteDelimiter) void
setQuotedArgumentsEnabled
(boolean quotedArgumentsEnabled) void
setQuotedExecutableEnabled
(boolean quotedExecutableEnabled) void
setShellArgs
(String[] shellArgs) Set the shell arguments when calling a command line (not the executable arguments) (eg.void
setShellCommand
(String shellCommand) Set the command to execute the shell (eg.protected void
setSingleQuotedArgumentEscaped
(boolean singleQuotedArgumentEscaped) protected void
setSingleQuotedExecutableEscaped
(boolean singleQuotedExecutableEscaped) void
setUnconditionalQuoting
(boolean unconditionallyQuote) Toggle unconditional quotingvoid
setWorkingDirectory
(File workingDir) void
setWorkingDirectory
(String path)
-
Constructor Details
-
Shell
public Shell()
-
-
Method Details
-
setUnconditionalQuoting
public void setUnconditionalQuoting(boolean unconditionallyQuote) Toggle unconditional quoting- Parameters:
unconditionallyQuote
- see name
-
setShellCommand
Set the command to execute the shell (eg. COMMAND.COM, /bin/bash,...)- Parameters:
shellCommand
- see name
-
getShellCommand
-
setShellArgs
Set the shell arguments when calling a command line (not the executable arguments) (eg. /X /C for CMD.EXE)- Parameters:
shellArgs
- see name
-
getShellArgs
- Returns:
- the shell arguments
-
getCommandLine
Get the command line for the provided executable and arguments in this shell- Parameters:
executable
- executable that the shell has to callarguments
- arguments for the executable, not the shell- Returns:
- List with one String object with executable and arguments quoted as needed
-
quoteOneItem
-
getRawCommandLine
-
getQuotingTriggerChars
protected char[] getQuotingTriggerChars() -
getExecutionPreamble
-
getEscapeChars
protected char[] getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote) -
isDoubleQuotedArgumentEscaped
protected boolean isDoubleQuotedArgumentEscaped() -
isSingleQuotedArgumentEscaped
protected boolean isSingleQuotedArgumentEscaped() -
isDoubleQuotedExecutableEscaped
protected boolean isDoubleQuotedExecutableEscaped() -
isSingleQuotedExecutableEscaped
protected boolean isSingleQuotedExecutableEscaped() -
setArgumentQuoteDelimiter
protected void setArgumentQuoteDelimiter(char argQuoteDelimiter) -
getArgumentQuoteDelimiter
protected char getArgumentQuoteDelimiter() -
setExecutableQuoteDelimiter
protected void setExecutableQuoteDelimiter(char exeQuoteDelimiter) -
getExecutableQuoteDelimiter
protected char getExecutableQuoteDelimiter() -
setArgumentEscapePattern
-
getArgumentEscapePattern
-
getShellCommandLine
Get the full command line to execute, including shell command, shell arguments, executable and executable arguments- Parameters:
arguments
- arguments for the executable, not the shell- Returns:
- List of String objects, whose array version is suitable to be used as argument of Runtime.getRuntime().exec()
-
getShellArgsList
-
addShellArg
-
setQuotedArgumentsEnabled
public void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled) -
isQuotedArgumentsEnabled
public boolean isQuotedArgumentsEnabled() -
setQuotedExecutableEnabled
public void setQuotedExecutableEnabled(boolean quotedExecutableEnabled) -
isQuotedExecutableEnabled
public boolean isQuotedExecutableEnabled() -
setExecutable
- Parameters:
executable
- Sets the executable to run.
-
getExecutable
-
setWorkingDirectory
- Parameters:
path
- Sets execution directory.
-
setWorkingDirectory
- Parameters:
workingDir
- Sets execution directory.
-
getWorkingDirectory
-
getWorkingDirectoryAsString
-
clearArguments
public void clearArguments() -
clone
-
getOriginalExecutable
-
getOriginalCommandLine
-
setDoubleQuotedArgumentEscaped
protected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped) -
setDoubleQuotedExecutableEscaped
protected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped) -
setSingleQuotedArgumentEscaped
protected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped) -
setSingleQuotedExecutableEscaped
protected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)
-