org.codehaus.plexus.util.cli.shell

## Class CmdShell

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

All Implemented Interfaces:
  Cloneable

    public class CmdShell
    extends Shell

Implementation to call the CMD Shell present on Windows NT, 2000 and XP

Since:
  1.2
Version:
  $Id: CmdShell.java 8010 2009-01-07 12:59:50Z vsiveton $
Author:
  Carlos Sanchez

### Constructor Summary

Constructors
Constructor and Description
`CmdShell()`

### Method Summary

Methods
`List` `getCommandLine(String executable, String[] arguments)` Specific implementation that quotes all the command line.

### Methods inherited from class org.codehaus.plexus.util.cli.shell.Shell

`addShellArg, clearArguments, clone, getArgumentQuoteDelimiter, getEscapeChars, getExecutable, getExecutableQuoteDelimiter, getExecutionPreamble, getOriginalCommandLine, getOriginalExecutable, getQuotingTriggerChars, getRawCommandLine, getShellArgs, getShellArgsList, getShellCommand, getShellCommandLine, getWorkingDirectory, getWorkingDirectoryAsString, isDoubleQuotedArgumentEscaped, isDoubleQuotedExecutableEscaped, isQuotedArgumentsEnabled, isQuotedExecutableEnabled, isSingleQuotedArgumentEscaped, isSingleQuotedExecutableEscaped, quoteOneItem, setArgumentQuoteDelimiter, setDoubleQuotedArgumentEscaped, setDoubleQuotedExecutableEscaped, setExecutable, setExecutableQuoteDelimiter, setQuotedArgumentsEnabled, setQuotedExecutableEnabled, setShellArgs, setShellCommand, setSingleQuotedArgumentEscaped, setSingleQuotedExecutableEscaped, setUnconditionalQuoting, setWorkingDirectory, setWorkingDirectory`

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

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

### Constructor Detail

#### CmdShell

    public CmdShell()

### Method Detail

#### getCommandLine

    public List getCommandLine(String executable,
                      String[] arguments)

Specific implementation that quotes all the command line.

Workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468220

From cmd.exe /? output:

          If /C or /K is specified, then the remainder of the command line after
          the switch is processed as a command line, where the following logic is
          used to process quote (") characters:

          1.  If all of the following conditions are met, then quote characters
          on the command line are preserved:

          - no /S switch
          - exactly two quote characters
          - no special characters between the two quote characters,
          where special is one of: &<>()@ˆ|
          - there are one or more whitespace characters between the
          the two quote characters
          - the string between the two quote characters is the name
          of an executable file.

          2.  Otherwise, old behavior is to see if the first character is
          a quote character and if so, strip the leading character and
          remove the last quote character on the command line, preserving
          any text after the last quote character.

Always quoting the entire command line, regardless of these conditions appears to make Windows processes invoke successfully.

Overrides:
  `getCommandLine` in class `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