MauiKit Terminal

ShellCommand.h
1/*
2 SPDX-FileCopyrightText: 2007-2008 Robert Knight <robertknight@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#ifndef SHELLCOMMAND_H
8#define SHELLCOMMAND_H
9
10// Qt
11#include <QStringList>
12
13namespace Konsole
14{
15/**
16 * A class to parse and extract information about shell commands.
17 *
18 * ShellCommand can be used to:
19 *
20 * <ul>
21 * <li>Take a command-line (eg "/bin/sh -c /path/to/my/script") and split it
22 * into its component parts (eg. the command "/bin/sh" and the arguments
23 * "-c","/path/to/my/script")
24 * </li>
25 * <li>Take a command and a list of arguments and combine them to
26 * form a complete command line.
27 * </li>
28 * <li>Determine whether the binary specified by a command exists in the
29 * user's PATH.
30 * </li>
31 * <li>Determine whether a command-line specifies the execution of
32 * another command as the root user using su/sudo etc.
33 * </li>
34 * </ul>
35 */
37{
38public:
39 /**
40 * Constructs a ShellCommand from a command line.
41 *
42 * @param aCommand The command line to parse.
43 */
44 explicit ShellCommand(const QString &aCommand);
45 /**
46 * Constructs a ShellCommand with the specified @p aCommand and @p aArguments.
47 */
48 ShellCommand(const QString &aCommand, const QStringList &aArguments);
49
50 /** Returns the command. */
51 QString command() const;
52 /** Returns the arguments. */
53 QStringList arguments() const;
54
55 /**
56 * Returns the full command line.
57 */
58 QString fullCommand() const;
59
60 /** Expands environment variables in @p text .*/
61 static QString expand(const QString &text);
62
63 /** Expands environment variables in each string in @p list. */
64 static QStringList expand(const QStringList &items);
65
66 static bool isValidEnvCharacter(const QChar &ch);
67
68 static bool isValidLeadingEnvCharacter(const QChar &ch);
69
70private:
71 static bool expandEnv(QString &text);
72
73 QStringList _arguments;
74};
75}
76
77#endif // SHELLCOMMAND_H
A class to parse and extract information about shell commands.
QStringList arguments() const
Returns the arguments.
QString fullCommand() const
Returns the full command line.
ShellCommand(const QString &aCommand)
Constructs a ShellCommand from a command line.
static QString expand(const QString &text)
Expands environment variables in text .
QString command() const
Returns the command.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:57:30 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.