From f4f8d8bb1abc79c4186ee8dc2ea536d62c6cb149 Mon Sep 17 00:00:00 2001 From: Roland Gaudig Date: Fri, 23 Jul 2021 12:29:21 +0000 Subject: cmd: setexpr: add format string handling Add format string handling operator to the setexpr command. It allows to use C or Bash like format string expressions to be evaluated with the result being stored inside the environment variable name. setexpr fmt [value]... The following example setexpr foo fmt "%d, 0x%x" 0x100 ff will result in $foo being set to "256, 0xff". Signed-off-by: Roland Gaudig Reviewed-by: Simon Glass --- cmd/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cmd/Kconfig') diff --git a/cmd/Kconfig b/cmd/Kconfig index e40d390f882..f1bcf9ebde3 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1414,6 +1414,14 @@ config CMD_SETEXPR Also supports loading the value at a memory location into a variable. If CONFIG_REGEX is enabled, setexpr also supports a gsub function. +config CMD_SETEXPR_FMT + bool "setexpr_fmt" + default n + depends on CMD_SETEXPR + help + Evaluate format string expression and store result in an environment + variable. + endmenu menu "Android support commands" -- cgit v1.2.3