public Object clone() { Shell shell = new Shell(); shell.setExecutable( getExecutable() ); shell.setWorkingDirectory( getWorkingDirectory() ); shell.setShellArgs( getShellArgs() ); return shell; }
/** * Sets execution directory. */ public void setWorkingDirectory( File workingDirectory ) { shell.setWorkingDirectory( workingDirectory ); workingDir = workingDirectory; }
/** * Sets the executable to run. */ public void setExecutable( String executable ) { shell.setExecutable( executable ); this.executable = executable; }
public BourneShell( boolean isLoginShell ) { setUnconditionalQuoting( true ); setShellCommand( "/bin/sh" ); setArgumentQuoteDelimiter( '\'' ); setExecutableQuoteDelimiter( '\'' ); setSingleQuotedArgumentEscaped( true ); setSingleQuotedExecutableEscaped( false ); setQuotedExecutableEnabled( true ); setArgumentEscapePattern( "'\\%s'" ); if ( isLoginShell ) { addShellArg( "-l" ); } }
protected String quoteOneItem( String inputString, boolean isExecutable ) { char[] escapeChars = getEscapeChars( isSingleQuotedExecutableEscaped(), isDoubleQuotedExecutableEscaped() ); return StringUtils.quoteAndEscape( inputString, isExecutable ? getExecutableQuoteDelimiter() : getArgumentQuoteDelimiter(), escapeChars, getQuotingTriggerChars(), '\\', unconditionallyQuote ); }
/** * @deprecated Remove once backward compat with plexus-utils <= 1.4 is no longer a consideration */ private void verifyShellState() { if ( shell.getWorkingDirectory() == null ) { shell.setWorkingDirectory( workingDir ); } if ( shell.getOriginalExecutable() == null ) { shell.setExecutable( executable ); } }
public CmdShell() { setShellCommand( "cmd.exe" ); setQuotedExecutableEnabled( true ); setShellArgs( new String[] { "/X", "/C" } ); }
/** {@inheritDoc} */ public String getExecutable() { if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { return super.getExecutable(); } return quoteOneItem( super.getOriginalExecutable(), true ); }
/** * <p> * Sets the shell or command-line interpreter for the detected operating system, and the shell arguments. * </p> */ private void setDefaultShell() { // If this is windows set the shell to command.com or cmd.exe with correct arguments. if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) { if ( Os.isFamily( Os.FAMILY_WIN9X ) ) { setShell( new CommandShell() ); } else { setShell( new CmdShell() ); } } else { setShell( new BourneShell() ); } }
public CommandShell() { setShellCommand( "command.com" ); setShellArgs( new String[] { "/C" } ); }
/** * Clear out the whole command line. */ public void clear() { executable = null; workingDir = null; shell.setExecutable( null ); shell.clearArguments(); arguments.removeAllElements(); }
protected String getExecutionPreamble() { if ( getWorkingDirectoryAsString() == null ) { return null; } String dir = getWorkingDirectoryAsString(); StringBuilder sb = new StringBuilder(); sb.append( "cd " ); sb.append( quoteOneItem( dir, false ) ); sb.append( " && " ); return sb.toString(); }
/** * Get the command line for the provided executable and arguments in this shell * * @param executable executable that the shell has to call * @param arguments arguments for the executable, not the shell * @return List with one String object with executable and arguments quoted as needed */ public List<String> getCommandLine( String executable, String[] arguments ) { return getRawCommandLine( executable, arguments ); }
public File getWorkingDirectory() { File workDir = shell.getWorkingDirectory(); if ( workDir == null ) { workDir = workingDir; } return workDir; }
/** * Return an executable name, quoted for shell use. Shell usage is only desirable when generating code for remote * execution. * * @return Executable to be run, quoted for shell interpretation */ public String getExecutable() { String exec = shell.getExecutable(); if ( exec == null ) { exec = executable; } return exec; }
@Override public String[] getShellArgs() { String[] shellArgs = super.getShellArgs(); if ( shellArgs == null ) { shellArgs = new String[ 0 ]; } return shellArgs; }
public List<String> getShellArgsList() { List<String> shellArgs = new ArrayList<String>(); List<String> existingShellArgs = super.getShellArgsList(); if ( ( existingShellArgs != null ) && !existingShellArgs.isEmpty() ) { shellArgs.addAll( existingShellArgs ); } shellArgs.add( "-c" ); return shellArgs; }
public Object clone() { Commandline c = new Commandline( (Shell) shell.clone() ); c.executable = executable; c.workingDir = workingDir; c.addArguments( getArguments() ); return c; }
/** * Sets execution directory. */ public void setWorkingDirectory( String path ) { shell.setWorkingDirectory( path ); workingDir = new File( path ); }
public List<String> getOriginalCommandLine( String executable, String[] arguments ) { return getRawCommandLine( executable, arguments ); }