Retrieves the value of an environment variable.
More...
#include <command_env.h>
|
|
| command_getenv () |
| | Constructs command.
|
| |
| shell_status | run (const std::span< const std::string > &vArgs, shell_session &oSession) const override |
| | Prints the env variable value on stdout. If the env variable does not exist, does nothing.
|
| |
| virtual void | msg_error_param_number (std::ostream &oStdErr, std::size_t nArgs) const |
| | Print an error if the wrong number of arguments is provided.
|
| |
| virtual void | msg_error_variable_name (std::ostream &oStdErr, const std::string &sVariableName) const |
| | Print an error if variable name is invalid.
|
| |
Public Member Functions inherited from bs::command |
| | command (std::string sName) |
| | Construct a command with a given name.
|
| |
|
virtual | ~command ()=default |
| | Virtual destructor.
|
| |
| std::string | get_name () const |
| | Get the command name (copy).
|
| |
| const std::string & | get_name_ref () const noexcept |
| | Get the command name (reference).
|
| |
Retrieves the value of an environment variable.
Syntax: getenv variable
◆ msg_error_param_number()
| void bs::command_getenv::msg_error_param_number |
( |
std::ostream & |
oStdErr, |
|
|
std::size_t |
nArgs |
|
) |
| const |
|
virtual |
Print an error if the wrong number of arguments is provided.
- Parameters
-
| oStdErr | Stream to print error message. |
| nArgs | Number of provided arguments. |
◆ msg_error_variable_name()
| void bs::command_getenv::msg_error_variable_name |
( |
std::ostream & |
oStdErr, |
|
|
const std::string & |
sVariableName |
|
) |
| const |
|
virtual |
Print an error if variable name is invalid.
- Parameters
-
| oStdErr | Stream to print error message. |
| sVariableName | Variable name provided. |
◆ run()
Prints the env variable value on stdout. If the env variable does not exist, does nothing.
If the parameter number does not match 1 then method msg_error_param_number is called. If the variable names is invalid then method msg_error_variable_name is called.
- Parameters
-
| vArgs | Arguments for the command. |
| oSession | The shell session context. |
- Returns
- Status of command execution.
Implements bs::command.
The documentation for this class was generated from the following files:
- /home/runner/work/bashspark/bashspark/include/BashSpark/command/command_env.h
- /home/runner/work/bashspark/bashspark/src/BashSpark/command/command_env.cpp