Skip to content

eval_cmd

Ekarin Eric Pongpipat edited this page Sep 12, 2024 · 1 revision

Function to evaluate a string command with some extra checks and options

Usage

Example 1

eval_cmd -c "${cmd}" -o /path/to/output.txt

Note: The command must be wrapped in quotes

Example 2

You can specify more than one output file to be checked if they exist before running. If any of the output files exist, it will skip evaluating the command. After evaluating the command, the function will ensure that each output file exists and will error if they do not.

eval_cmd -c "${cmd}" -o /path/to/output1.txt -o /path/to/output2.txt

Example 3

By default, if one of the output files exists, it will not run unless the overwrite flag is used.

eval_cmd -c "${cmd}" -o /path/to/output.txt --overwrite 1

Example 4

You can also print the command without evaluating it, which is useful for debugging

eval_cmd -c "${cmd}" -o /path/to/output.txt --print 1
Clone this wiki locally