Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / konsole / src / ShellCommand.h
blob5a5089d24f31fd4e6a0239bceb3c55ec96f7779d
1 /*
2 Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301 USA.
20 #ifndef SHELLCOMMAND_H
21 #define SHELLCOMMAND_H
23 // Qt
24 #include <QtCore/QStringList>
26 namespace Konsole
29 /**
30 * A class to parse and extract information about shell commands.
32 * ShellCommand can be used to:
34 * <ul>
35 * <li>Take a command-line (eg "/bin/sh -c /path/to/my/script") and split it
36 * into its component parts (eg. the command "/bin/sh" and the arguments
37 * "-c","/path/to/my/script")
38 * </li>
39 * <li>Take a command and a list of arguments and combine them to
40 * form a complete command line.
41 * </li>
42 * <li>Determine whether the binary specified by a command exists in the
43 * user's PATH.
44 * </li>
45 * <li>Determine whether a command-line specifies the execution of
46 * another command as the root user using su/sudo etc.
47 * </li>
48 * </ul>
50 class ShellCommand
52 public:
53 /**
54 * Constructs a ShellCommand from a command line.
56 * @param fullCommand The command line to parse.
58 ShellCommand(const QString& fullCommand);
59 /**
60 * Constructs a ShellCommand with the specified @p command and @p arguments.
62 ShellCommand(const QString& command , const QStringList& arguments);
64 /** Returns the command. */
65 QString command() const;
66 /** Returns the arguments. */
67 QStringList arguments() const;
69 /**
70 * Returns the full command line.
72 QString fullCommand() const;
74 /** Returns true if this is a root command. */
75 bool isRootCommand() const;
76 /** Returns true if the program specified by @p command() exists. */
77 bool isAvailable() const;
79 /** Expands environment variables in @p text .*/
80 static QString expand(const QString& text);
82 /** Expands environment variables in each string in @p list. */
83 static QStringList expand(const QStringList& items);
85 private:
86 QStringList _arguments;
91 #endif // SHELLCOMMAND_H