.TH "KShell" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KShell \- Provides some basic POSIX shell and bash functionality.  

.PP
.SH SYNOPSIS
.br
.PP
.SS "Enumerations"

.in +1c
.ti -1c
.RI "enum \fBOptions\fP { \fBNoOptions\fP =  0, \fBTildeExpand\fP =  1, \fBAbortOnMeta\fP =  2 }"
.br
.ti -1c
.RI "enum \fBErrors\fP { \fBNoError\fP =  0, \fBBadQuoting\fP, \fBFoundMeta\fP }"
.br
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "KDECORE_EXPORT \fBQStringList\fP \fBsplitArgs\fP (const \fBQString\fP &cmd, int flags=0, int *err=0)"
.br
.ti -1c
.RI "KDECORE_EXPORT \fBQString\fP \fBjoinArgs\fP (const \fBQStringList\fP &args)"
.br
.ti -1c
.RI "KDECORE_EXPORT \fBQString\fP \fBjoinArgsDQ\fP (const \fBQStringList\fP &args)"
.br
.ti -1c
.RI "KDECORE_EXPORT \fBQString\fP \fBjoinArgs\fP (const char *const *argv, int argc=-1)"
.br
.ti -1c
.RI "KDECORE_EXPORT \fBQString\fP \fBtildeExpand\fP (const \fBQString\fP &path)"
.br
.ti -1c
.RI "KDECORE_EXPORT \fBQString\fP \fBhomeDir\fP (const \fBQString\fP &user)"
.br
.in -1c
.SH "Detailed Description"
.PP 
Provides some basic POSIX shell and bash functionality. 

\fBSee also:\fP
.RS 4
\fBKStringHandler\fP 
.RE
.PP

.PP
.SH "Enumeration Type Documentation"
.PP 
.SS "enum \fBKShell::Options\fP"
.PP
Flags for \fBsplitArgs()\fP. 
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fITildeExpand \fP\fP
Perform tilde expansion. 
.TP
\fB\fIAbortOnMeta \fP\fP
Bail out if a non-quoting and not quoted shell meta character is encoutered. 
.PP
Meta characters are the command separators \fCsemicolon\fP and \fCampersand\fP, the redirection symbols \fCless-than\fP, \fCgreater-than\fP and the \fCpipe\fP \fCsymbol\fP, the grouping symbols opening and closing \fCparens\fP and \fCbraces\fP, the command substitution symbol \fCbackquote\fP, the generic substitution symbol \fCdollar\fP (if not followed by an apostrophe), the wildcards \fCasterisk\fP and \fCquestion\fP \fCmark\fP, and the comment symbol \fChash\fP \fCmark\fP. Additionally, a variable assignment in the first word is recognized. 
.PP
Definition at line 38 of file kshell.h.
.SS "enum \fBKShell::Errors\fP"
.PP
Status codes from \fBsplitArgs()\fP. 
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fINoError \fP\fP
Success. 
.TP
\fB\fIBadQuoting \fP\fP
Indicates a parsing error, like an unterminated quoted string. 
.TP
\fB\fIFoundMeta \fP\fP
The AbortOnMeta flag was set and a shell meta character was encoutered. 
.PP
Definition at line 62 of file kshell.h.
.SH "Function Documentation"
.PP 
.SS "\fBQStringList\fP KShell::splitArgs (const \fBQString\fP & cmd, int flags = \fC0\fP, int * err = \fC0\fP)"
.PP
Splits \fCcmd\fP according to POSIX shell word splitting and quoting rules. 
.PP
Can optionally perform tilde expansion and/or abort if it finds shell meta characters it cannot process.
.PP
\fBParameters:\fP
.RS 4
\fIcmd\fP the command to split 
.br
\fIflags\fP operation flags, see Options 
.br
\fIerr\fP if not NULL, a status code will be stored at the pointer target, see Errors 
.RE
.PP
\fBReturns:\fP
.RS 4
a list of unquoted words or an empty list if an error occurred 
.RE
.PP

.PP
Definition at line 65 of file kshell.cpp.
.PP
References AbortOnMeta, BadQuoting, FoundMeta, homeDir(), QString::isEmpty(), QChar::isSpace(), NoError, TildeExpand, and QChar::unicode().
.PP
Referenced by KApplication::invokeMailer().
.SS "\fBQString\fP KShell::joinArgs (const \fBQStringList\fP & args)"
.PP
Quotes and joins \fCargs\fP together according to POSIX shell rules. 
.PP
\fBParameters:\fP
.RS 4
\fIargs\fP a list of strings to quote and join 
.RE
.PP
\fBReturns:\fP
.RS 4
a command suitable for shell execution 
.RE
.PP

.PP
Definition at line 257 of file kshell.cpp.
.PP
References QString::append(), QString::isEmpty(), and QString::replace().
.SS "\fBQString\fP KShell::joinArgsDQ (const \fBQStringList\fP & args)"
.PP
Same as above, but $'' is used instead of '' for the quoting. 
.PP
The output is suitable for \fBsplitArgs()\fP, 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.
.PP
\fBParameters:\fP
.RS 4
\fIargs\fP a list of strings to quote and join 
.RE
.PP
\fBReturns:\fP
.RS 4
a command suitable for shell execution 
.RE
.PP

.PP
Definition at line 311 of file kshell.cpp.
.PP
References QString::append(), QString::isEmpty(), and QString::unicode().
.SS "\fBQString\fP KShell::joinArgs (const char *const * argv, int argc = \fC-1\fP)"
.PP
Quotes and joins \fCargv\fP together according to POSIX shell rules. 
.PP
\fBParameters:\fP
.RS 4
\fIargv\fP an array of c strings to quote and join. The strings are expected to be in local-8-bit encoding. 
.br
\fIargc\fP maximal number of strings in \fCargv\fP. if not supplied, \fCargv\fP must be null-terminated. 
.RE
.PP
\fBReturns:\fP
.RS 4
a command suitable for shell execution 
.RE
.PP

.PP
Definition at line 283 of file kshell.cpp.
.PP
References QString::append(), QString::isEmpty(), QString::length(), QString::replace(), and QString::unicode().
.SS "\fBQString\fP KShell::tildeExpand (const \fBQString\fP & path)"
.PP
Performs tilde expansion on \fCpath\fP. 
.PP
Interprets '~/path' and '~user/path'.
.PP
\fBParameters:\fP
.RS 4
\fIpath\fP the path to tilde-expand 
.RE
.PP
\fBReturns:\fP
.RS 4
the expanded path 
.RE
.PP

.PP
Definition at line 355 of file kshell.cpp.
.PP
References QString::find(), homeDir(), and QString::isNull().
.PP
Referenced by KStandardDirs::addKDEDefaults().
.SS "\fBQString\fP KShell::homeDir (const \fBQString\fP & user)"
.PP
Obtain a \fCuser's\fP home directory. 
.PP
\fBParameters:\fP
.RS 4
\fIuser\fP The name of the user whose home dir should be obtained. An empty string denotes the current user. 
.RE
.PP
\fBReturns:\fP
.RS 4
The user's home directory. 
.RE
.PP

.PP
Definition at line 369 of file kshell.cpp.
.PP
References QFile::decodeName().
.PP
Referenced by splitArgs(), and tildeExpand().
.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
