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/printf.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 cmd/printf.h (limited to 'cmd/printf.h') diff --git a/cmd/printf.h b/cmd/printf.h new file mode 100644 index 00000000000..dcaff6d0972 --- /dev/null +++ b/cmd/printf.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef __PRINTF_H +#define __PRINTF_H + +int printf_setexpr(char *str, size_t size, int argc, char *const *argv); + +#endif -- cgit v1.2.3