org.codehaus.plexus.util.cli.shell

## Class Shell

- java.lang.Object
- - org.codehaus.plexus.util.cli.shell.Shell

- All Implemented Interfaces:
    java.lang.Cloneable
  Direct Known Subclasses:
    BourneShell, CmdShell, CommandShell

      public class Shell
      extends java.lang.Object
      implements java.lang.Cloneable

  Class that abstracts the Shell functionality, with subclases for shells that behave particularly, like

  - `command.com`
  - `cmd.exe`
  Since:
    1.2
  Version:
    $Id: Shell.java 8010 2009-01-07 12:59:50Z vsiveton $
  Author:
    Carlos Sanchez

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Shell()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addShellArg(java.lang.String arg)`
    `void` | `clearArguments()`
    `java.lang.Object` | `clone()`
    `protected char` | `getArgumentQuoteDelimiter()`
    `java.util.List` | `getCommandLine(java.lang.String executable, java.lang.String[] arguments)` Get the command line for the provided executable and arguments in this shell
    `protected char[]` | `getEscapeChars(boolean includeSingleQuote, boolean includeDoubleQuote)`
    `java.lang.String` | `getExecutable()`
    `protected char` | `getExecutableQuoteDelimiter()`
    `protected java.lang.String` | `getExecutionPreamble()`
    `java.util.List` | `getOriginalCommandLine(java.lang.String executable, java.lang.String[] arguments)`
    `java.lang.String` | `getOriginalExecutable()`
    `protected char[]` | `getQuotingTriggerChars()`
    `protected java.util.List` | `getRawCommandLine(java.lang.String executable, java.lang.String[] arguments)`
    `java.lang.String[]` | `getShellArgs()` Get the shell arguments
    `java.util.List` | `getShellArgsList()`
    `java.lang.String` | `getShellCommand()` Get the command to execute the shell
    `java.util.List` | `getShellCommandLine(java.lang.String[] arguments)` Get the full command line to execute, including shell command, shell arguments, executable and executable arguments
    `java.io.File` | `getWorkingDirectory()`
    `java.lang.String` | `getWorkingDirectoryAsString()`
    `protected boolean` | `isDoubleQuotedArgumentEscaped()`
    `protected boolean` | `isDoubleQuotedExecutableEscaped()`
    `boolean` | `isQuotedArgumentsEnabled()`
    `boolean` | `isQuotedExecutableEnabled()`
    `protected boolean` | `isSingleQuotedArgumentEscaped()`
    `protected boolean` | `isSingleQuotedExecutableEscaped()`
    `protected java.lang.String` | `quoteOneItem(java.lang.String inputString, boolean isExecutable)`
    `protected void` | `setArgumentQuoteDelimiter(char argQuoteDelimiter)`
    `protected void` | `setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)`
    `protected void` | `setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)`
    `void` | `setExecutable(java.lang.String executable)` Sets the executable to run.
    `protected void` | `setExecutableQuoteDelimiter(char exeQuoteDelimiter)`
    `void` | `setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)`
    `void` | `setQuotedExecutableEnabled(boolean quotedExecutableEnabled)`
    `void` | `setShellArgs(java.lang.String[] shellArgs)` Set the shell arguments when calling a command line (not the executable arguments) (eg.
    `void` | `setShellCommand(java.lang.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 quoting
    `void` | `setWorkingDirectory(java.io.File workingDir)` Sets execution directory.
    `void` | `setWorkingDirectory(java.lang.String path)` Sets execution directory.

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Shell

          public Shell()

  - ### Method Detail

    - #### setUnconditionalQuoting

          public void setUnconditionalQuoting(boolean unconditionallyQuote)

      Toggle unconditional quoting
      Parameters:
        `unconditionallyQuote` -

    - #### setShellCommand

          public void setShellCommand(java.lang.String shellCommand)

      Set the command to execute the shell (eg. COMMAND.COM, /bin/bash,...)
      Parameters:
        `shellCommand` -

    - #### getShellCommand

          public java.lang.String getShellCommand()

      Get the command to execute the shell
      Returns:

    - #### setShellArgs

          public void setShellArgs(java.lang.String[] shellArgs)

      Set the shell arguments when calling a command line (not the executable arguments) (eg. /X /C for CMD.EXE)
      Parameters:
        `shellArgs` -

    - #### quoteOneItem

          protected java.lang.String quoteOneItem(java.lang.String inputString,
                                                  boolean isExecutable)

    - #### getShellArgs

          public java.lang.String[] getShellArgs()

      Get the shell arguments
      Returns:

    - #### getCommandLine

          public java.util.List getCommandLine(java.lang.String executable,
                                               java.lang.String[] arguments)

      Get 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

    - #### getRawCommandLine

          protected java.util.List getRawCommandLine(java.lang.String executable,
                                                     java.lang.String[] arguments)

    - #### getQuotingTriggerChars

          protected char[] getQuotingTriggerChars()

    - #### getExecutionPreamble

          protected java.lang.String 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()

    - #### getShellCommandLine

          public java.util.List getShellCommandLine(java.lang.String[] arguments)

      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

          public java.util.List getShellArgsList()

    - #### addShellArg

          public void addShellArg(java.lang.String arg)

    - #### setQuotedArgumentsEnabled

          public void setQuotedArgumentsEnabled(boolean quotedArgumentsEnabled)

    - #### isQuotedArgumentsEnabled

          public boolean isQuotedArgumentsEnabled()

    - #### setQuotedExecutableEnabled

          public void setQuotedExecutableEnabled(boolean quotedExecutableEnabled)

    - #### isQuotedExecutableEnabled

          public boolean isQuotedExecutableEnabled()

    - #### setExecutable

          public void setExecutable(java.lang.String executable)

      Sets the executable to run.

    - #### getExecutable

          public java.lang.String getExecutable()

    - #### setWorkingDirectory

          public void setWorkingDirectory(java.lang.String path)

      Sets execution directory.

    - #### setWorkingDirectory

          public void setWorkingDirectory(java.io.File workingDir)

      Sets execution directory.

    - #### getWorkingDirectory

          public java.io.File getWorkingDirectory()

    - #### getWorkingDirectoryAsString

          public java.lang.String getWorkingDirectoryAsString()

    - #### clearArguments

          public void clearArguments()

    - #### clone

          public java.lang.Object clone()

      Overrides:
        `clone` in class `java.lang.Object`

    - #### getOriginalExecutable

          public java.lang.String getOriginalExecutable()

    - #### getOriginalCommandLine

          public java.util.List getOriginalCommandLine(java.lang.String executable,
                                                       java.lang.String[] arguments)

    - #### setDoubleQuotedArgumentEscaped

          protected void setDoubleQuotedArgumentEscaped(boolean doubleQuotedArgumentEscaped)

    - #### setDoubleQuotedExecutableEscaped

          protected void setDoubleQuotedExecutableEscaped(boolean doubleQuotedExecutableEscaped)

    - #### setSingleQuotedArgumentEscaped

          protected void setSingleQuotedArgumentEscaped(boolean singleQuotedArgumentEscaped)

    - #### setSingleQuotedExecutableEscaped

          protected void setSingleQuotedExecutableEscaped(boolean singleQuotedExecutableEscaped)