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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddShellArg(String arg) voidclone()protected Stringprotected chargetCommandLine(String executable, String[] arguments) Get the command line for the provided executable and arguments in this shellprotected char[]getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote) protected charprotected StringgetOriginalCommandLine(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 booleanprotected booleanbooleanbooleanprotected booleanprotected booleanprotected StringquoteOneItem(String inputString, boolean isExecutable) protected voidsetArgumentEscapePattern(String argumentEscapePattern) protected voidsetArgumentQuoteDelimiter(char argQuoteDelimiter) protected voidsetDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped) protected voidsetDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped) voidsetExecutable(String executable) protected voidsetExecutableQuoteDelimiter(char exeQuoteDelimiter) voidsetQuotedArgumentsEnabled(boolean quotedArgumentsEnabled) voidsetQuotedExecutableEnabled(boolean quotedExecutableEnabled) voidsetShellArgs(String[] shellArgs) Set the shell arguments when calling a command line (not the executable arguments) (eg.voidsetShellCommand(String shellCommand) Set the command to execute the shell (eg.protected voidsetSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped) protected voidsetSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped) voidsetUnconditionalQuoting(boolean unconditionallyQuote) Toggle unconditional quotingvoidsetWorkingDirectory(File workingDir) voidsetWorkingDirectory(String path) 
- 
Constructor Details- 
Shellpublic Shell()
 
- 
- 
Method Details- 
setUnconditionalQuotingpublic void setUnconditionalQuoting(boolean unconditionallyQuote) Toggle unconditional quoting- Parameters:
- unconditionallyQuote- see name
 
- 
setShellCommandSet the command to execute the shell (eg. COMMAND.COM, /bin/bash,...)- Parameters:
- shellCommand- see name
 
- 
getShellCommandGet the command to execute the shell- Returns:
- the command
 
- 
setShellArgsSet 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
 
- 
getCommandLineGet the command line for the provided executable and arguments in this shell- Parameters:
- executable- executable that the shell has to call
- arguments- arguments for the executable, not the shell
- Returns:
- List with one String object with executable and arguments quoted as needed
 
- 
quoteOneItem
- 
getRawCommandLine
- 
getQuotingTriggerCharsprotected char[] getQuotingTriggerChars()
- 
getExecutionPreamble
- 
getEscapeCharsprotected char[] getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote) 
- 
isDoubleQuotedArgumentEscapedprotected boolean isDoubleQuotedArgumentEscaped()
- 
isSingleQuotedArgumentEscapedprotected boolean isSingleQuotedArgumentEscaped()
- 
isDoubleQuotedExecutableEscapedprotected boolean isDoubleQuotedExecutableEscaped()
- 
isSingleQuotedExecutableEscapedprotected boolean isSingleQuotedExecutableEscaped()
- 
setArgumentQuoteDelimiterprotected void setArgumentQuoteDelimiter(char argQuoteDelimiter) 
- 
getArgumentQuoteDelimiterprotected char getArgumentQuoteDelimiter()
- 
setExecutableQuoteDelimiterprotected void setExecutableQuoteDelimiter(char exeQuoteDelimiter) 
- 
getExecutableQuoteDelimiterprotected char getExecutableQuoteDelimiter()
- 
setArgumentEscapePattern
- 
getArgumentEscapePattern
- 
getShellCommandLineGet 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
- 
setQuotedArgumentsEnabledpublic void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled) 
- 
isQuotedArgumentsEnabledpublic boolean isQuotedArgumentsEnabled()
- 
setQuotedExecutableEnabledpublic void setQuotedExecutableEnabled(boolean quotedExecutableEnabled) 
- 
isQuotedExecutableEnabledpublic 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
- 
clearArgumentspublic void clearArguments()
- 
clone
- 
getOriginalExecutable
- 
getOriginalCommandLine
- 
setDoubleQuotedArgumentEscapedprotected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped) 
- 
setDoubleQuotedExecutableEscapedprotected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped) 
- 
setSingleQuotedArgumentEscapedprotected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped) 
- 
setSingleQuotedExecutableEscapedprotected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped) 
 
-