• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Enumerations | Functions
KShell Namespace Reference

Enumerations

enum  Options { NoOptions = 0 , TildeExpand = 1 , AbortOnMeta = 2 }
 
enum  Errors { NoError = 0 , BadQuoting , FoundMeta }
 

Functions

TQStringList splitArgs (const TQString &cmd, int flags=0, int *err=0)
 
TQString joinArgs (const TQStringList &args)
 
TQString joinArgsDQ (const TQStringList &args)
 
TQString joinArgs (const char *const *argv, int argc=-1)
 
TQString tildeExpand (const TQString &path)
 
TQString homeDir (const TQString &user)
 

Detailed Description

Provides some basic POSIX shell and bash functionality.

See also
KStringHandler
Since
3.2

Enumeration Type Documentation

◆ Errors

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.

◆ Options

enum KShell::Options

Flags for splitArgs().

Enumerator
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 40 of file kshell.h.

Function Documentation

◆ homeDir()

TQString KShell::homeDir ( const TQString &  user)

Obtain a user's home directory.

Parameters
userThe name of the user whose home dir should be obtained. An empty string denotes the current user.
Returns
The user's home directory.

Definition at line 369 of file kshell.cpp.

◆ joinArgs() [1/2]

TQString KShell::joinArgs ( const char *const *  argv,
int  argc = -1 
)

Quotes and joins argv together according to POSIX shell rules.

Parameters
argvan array of c strings to quote and join. The strings are expected to be in local-8-bit encoding.
argcmaximal number of strings in argv. if not supplied, argv must be null-terminated.
Returns
a command suitable for shell execution

Definition at line 283 of file kshell.cpp.

◆ joinArgs() [2/2]

TQString KShell::joinArgs ( const TQStringList &  args)

Quotes and joins args together according to POSIX shell rules.

Parameters
argsa list of strings to quote and join
Returns
a command suitable for shell execution

Definition at line 257 of file kshell.cpp.

◆ joinArgsDQ()

TQString KShell::joinArgsDQ ( const TQStringList &  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
argsa list of strings to quote and join
Returns
a command suitable for shell execution

Definition at line 311 of file kshell.cpp.

◆ splitArgs()

TQStringList KShell::splitArgs ( const TQString &  cmd,
int  flags = 0,
int *  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
cmdthe command to split
flagsoperation flags, see Options
errif 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 65 of file kshell.cpp.

◆ tildeExpand()

TQString KShell::tildeExpand ( const TQString &  path)

Performs tilde expansion on path.

Interprets "~/path" and "~user/path".

Parameters
paththe path to tilde-expand
Returns
the expanded path

Definition at line 355 of file kshell.cpp.

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.