org.kde.koala

Class KShell

public class KShell extends Object

\namespace KShell Provides some basic POSIX shell and bash functionality.

See Also: KStringHandler

UNKNOWN: \namespace KShell Provides some basic POSIX shell and bash functionality.

Field Summary
static intAbortOnMeta
static intBadQuoting
static intFoundMeta
static intNoError
Status codes from splitArgs()
static intNoOptions
Flags for splitArgs().
static intTildeExpand
Method Summary
static StringhomeDir(String user)
Obtain a user's home directory.
static StringjoinArgs(String[] args)
Quotes and joins args together according to POSIX shell rules.
static StringjoinArgsDQ(String[] args)
Same as above, but $'' is used instead of '' for the quoting.
static ArrayListsplitArgs(String cmd, int flags, int[] err)
Splits cmd according to POSIX shell word splitting and quoting rules.
static ArrayListsplitArgs(String cmd, int flags)
static ArrayListsplitArgs(String cmd)
static StringtildeExpand(String path)
Performs tilde expansion on path. Interprets "~/path" and "~user/path".

Field Detail

AbortOnMeta

public static final int AbortOnMeta

BadQuoting

public static final int BadQuoting

FoundMeta

public static final int FoundMeta

NoError

public static final int NoError
Status codes from splitArgs()

UNKNOWN: Status codes from splitArgs()

NoOptions

public static final int NoOptions
Flags for splitArgs().

UNKNOWN: Flags for splitArgs().

TildeExpand

public static final int TildeExpand

Method Detail

homeDir

public static String homeDir(String user)
Obtain a user's home directory.

Parameters: user The name of the user whose home dir should be obtained. An empty string denotes the current user.

Returns: The user's home directory.

UNKNOWN: Obtain a user's home directory.

joinArgs

public static String joinArgs(String[] args)
Quotes and joins args together according to POSIX shell rules.

Parameters: args a list of strings to quote and join

Returns: a command suitable for shell execution

UNKNOWN: Quotes and joins args together according to POSIX shell rules.

joinArgsDQ

public static String joinArgsDQ(String[] args)
Same as above, but $'' is used instead of '' for the quoting. The output is suitable for splitArgs(), bash, zsh and possibly other bourne-compatible shells, but not for plain sh. The advantage is, that control characters (ASCII less than 32) are escaped into human-readable strings.

Parameters: args a list of strings to quote and join

Returns: a command suitable for shell execution

UNKNOWN: Same as above, but $'' is used instead of '' for the quoting.

splitArgs

public static ArrayList splitArgs(String cmd, int flags, int[] err)
Splits cmd according to POSIX shell word splitting and quoting rules. Can optionally perform tilde expansion and/or abort if it finds shell meta characters it cannot process.

Parameters: cmd the command to split flags operation flags, see Options err if not NULL, a status code will be stored at the pointer target, see Errors

Returns: a list of unquoted words or an empty list if an error occurred

UNKNOWN: Splits cmd according to POSIX shell word splitting and quoting rules.

splitArgs

public static ArrayList splitArgs(String cmd, int flags)

splitArgs

public static ArrayList splitArgs(String cmd)

tildeExpand

public static String tildeExpand(String path)
Performs tilde expansion on path. Interprets "~/path" and "~user/path".

Parameters: path the path to tilde-expand

Returns: the expanded path

UNKNOWN: Performs tilde expansion on path.