• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

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().

Enumerator:
NoError  Success.
BadQuoting  Indicates a parsing error, like an unterminated quoted string.
FoundMeta  The AbortOnMeta flag was set and a shell meta character was encoutered.

Definition at line 64 of file kshell.h.

enum KShell::Option

Flags for splitArgs().

Enumerator:
NoOptions 
TildeExpand  Perform tilde expansion.
AbortOnMeta  Bail out if a non-quoting and not quoted shell meta character is encoutered.

Meta characters are the command separators semicolon and ampersand, the redirection symbols less-than, greater-than and the pipe symbol, the grouping symbols opening and closing parens and braces, the command substitution symbol backquote, the generic substitution symbol dollar (if not followed by an apostrophe), the wildcards asterisk and question mark, and the comment symbol hash mark. Additionally, a variable assignment in the first word is recognized.

Definition at line 39 of file kshell.h.


Function Documentation

QString KShell::homeDir ( const QString &  user  ) 

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.

QString KShell::quoteArg ( const QString &  arg  ) 

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.

QString KShell::tildeExpand ( const QString &  path  ) 

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.

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   WTF
  • KJSEmbed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  •   core
  • Phonon
  •   Backend
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal