KDECore
KShell Namespace Reference
Detailed Description
Provides some basic POSIX shell and bash functionality.
- See also:
- KStringHandler
Enumerations | |
| enum | Option { NoOptions = 0, TildeExpand = 1, AbortOnMeta = 2 } |
| enum | Errors { NoError = 0, BadQuoting, FoundMeta } |
Functions | |
| QString | homeDir (const QString &user) |
| QString | joinArgs (const QStringList &args) |
| QString | tildeExpand (const QString &path) |
| QStringList | splitArgs (const QString &cmd, Options flags=NoOptions, Errors *err=0) |
| QString | quoteArg (const QString &arg) |
Enumeration Type Documentation
| enum KShell::Errors |
Status codes from splitArgs().
| enum KShell::Option |
Flags for splitArgs().
- Enumerator:
Function Documentation
Definition at line 29 of file kshell.cpp.
| QString KShell::joinArgs | ( | const QStringList & | 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
Definition at line 38 of file kshell.cpp.
Quotes arg according to POSIX shell rules.
This function can be used to quote an argument string such that the shell processes it properly. This is e.g. necessary for user-provided file names which may contain spaces or quotes. It also prevents expansion of wild cards and environment variables.
- Parameters:
-
arg the argument to quote
- Returns:
- the quoted argument
Definition at line 273 of file kshell_unix.cpp.
| QStringList KShell::splitArgs | ( | const QString & | cmd, | |
| Options | flags = NoOptions, |
|||
| Errors * | err = 0 | |||
| ) |
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
Definition at line 72 of file kshell_unix.cpp.
Performs tilde expansion on path.
Interprets "~/path" and "~user/path". If the path starts with an escaped tilde ("\~" on UNIX, "^~" on Windows), the escape char is removed and the path is returned as is.
- Parameters:
-
path the path to tilde-expand
- Returns:
- the expanded path
Definition at line 55 of file kshell.cpp.
KDE 4.0 API Reference