2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 01:04:08 +08:00

ktest.pl: Add shell commands to variables

Allow variables to execute shell commands. Note, these are processed when
they are first seen while parsing the config file. This is useful if you
have the same config file used for multiple hosts (as they may be in a git
repository).

 HOSTNAME := ${shell hostname}
 DEFAULTS IF "${HOSTNAME}" == "frodo"

Link: https://lkml.kernel.org/r/20221207212944.277ee850@gandalf.local.home

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt (Google) 2022-12-07 21:29:44 -05:00
parent 26df05a8c1
commit 88a51b4f2e
2 changed files with 16 additions and 1 deletions

View File

@ -802,7 +802,14 @@ sub process_variables {
my $end = $3;
# append beginning of value to retval
$retval = "$retval$begin";
if (defined($variable{$var})) {
if ($var =~ s/^shell\s+//) {
$retval = `$var`;
if ($?) {
doprint "WARNING: $var returned an error\n";
} else {
chomp $retval;
}
} elsif (defined($variable{$var})) {
$retval = "$retval$variable{$var}";
} elsif (defined($remove_undef) && $remove_undef) {
# for if statements, any variable that is not defined,

View File

@ -259,6 +259,14 @@
# If PATH is not a config variable, then the ${PATH} in
# the MAKE_CMD option will be evaluated by the shell when
# the MAKE_CMD option is passed into shell processing.
#
# Shell commands can also be inserted with the ${shell <command>}
# expression. Note, this is case sensitive, thus ${SHELL <command>}
# will not work.
#
# HOSTNAME := ${shell hostname}
# DEFAULTS IF "${HOSTNAME}" == "frodo"
#
#### Using options in other options ####
#