Expand description
cmd_lib_macros - Procedural macros for cmd_lib
§Invalid syntax examples that should fail to compile
This section contains documentation tests that demonstrate invalid macro syntax which should result in compilation errors. These serve as tests to ensure the macros properly reject invalid input.
§Invalid variable expansion syntax
Variable names cannot start with numbers:
ⓘ
run_cmd!(echo "${msg0}");Invalid spacing in variable expansion:
ⓘ
run_fun!(echo "${ msg }");Unclosed variable expansion:
ⓘ
run_fun!(echo "${");Unclosed variable name:
ⓘ
run_fun!(echo "${msg");Variable names cannot be numbers:
ⓘ
run_fun!(echo "${0}");Variable names cannot have spaces:
ⓘ
run_fun!(echo "${ 0 }");Variable names cannot start with numbers:
ⓘ
run_fun!(echo "${0msg}");Variable names cannot contain spaces:
ⓘ
run_fun!(echo "${msg 0}");§Invalid redirect syntax
Invalid redirect operator spacing:
ⓘ
run_cmd!(ls > >&1);Invalid redirect to stdout:
ⓘ
run_cmd!(ls >>&1);Invalid redirect to stderr:
ⓘ
run_cmd!(ls >>&2);§Double redirect errors
Triple redirect operator:
ⓘ
run_cmd!(ls / /x &>>> /tmp/f);Double redirect with space:
ⓘ
run_cmd!(ls / /x &> > /tmp/f);Double output redirect:
ⓘ
run_cmd!(ls / /x > > /tmp/f);Append and output redirect:
ⓘ
run_cmd!(ls / /x >> > /tmp/f);Macros§
- cmd_die
- Log a fatal message at the error level, and exit process.
- run_cmd
- Run commands, returning
CmdResultto check status. - run_fun
- Run commands, returning
FunResultto capture output and to check status. - spawn
- Run commands with/without pipes as a child process, returning
CmdChildrenresult. - spawn_
with_ output - Run commands with/without pipes as a child process, returning
FunChildrenresult. - use_
custom_ cmd - Import user registered custom command.
Attribute Macros§
- main
- Mark main function to log error result by default.