1 .. SPDX-License-Identifier: GPL-2.0+
11 setexpr[.b, .w, .l .s] <name> [*]<value> <op> [*]<value2>
12 setexpr[.b, .w, .l] <name> [*]<value>
13 setexpr <name> fmt <format> [value]...
14 setexpr <name> gsub r s [t]
15 setexpr <name> sub r s [t]
20 The setexpr command is used to set an environment variable to the result
23 setexpr[.b, .w, .l .s] <name> [*]<value> <op> [*]<value2>
24 Set environment variable <name> to the result of the evaluated
25 expression specified by <op>.
27 setexpr[.b, .w, .l] name [*]value
28 Load <value> into environment variable <name>
30 setexpr name fmt <format> value
31 Set environment variable <name> to the result of the C like
32 format string <format> evaluation of <value>.
34 setexpr name gsub <r> <s> [<t>]
35 For each substring matching the regular expression <r> in the
36 string <t>, substitute the string <s>.
37 The result is assigned to <name>.
38 If <t> is not supplied, use the old value of <name>.
40 setexpr name sub <r> <s> [<t>]
41 Just like gsub(), but replace only the first matching substring
43 The setexpr command takes the following arguments:
46 This parameter contains a C or Bash like format string.
47 The number of arguments is limited to 4.
48 The following format types are supported:
59 unsigned decimal value
63 no conversion, instead a % character will be written
71 \c = produce no further output
77 \NNN = octal number (NNN is 0 to 3 digits)
80 The name of the environment variable to be set
89 (This is the only operator supported for strings.
90 It acts as concatenation operator on strings)
100 name = value % value2
112 Can either be an integer value, a string.
113 If the pointer prefix '*' is given value is treated as memory address.
123 => setexpr foo fmt %d 0x100
128 => setexpr foo fmt 0x%08x 63
133 => setexpr foo fmt %%%o 8
141 The setexpr gsub and sub operations are only available if CONFIG_REGEX=y.
146 The return value $? is set to 0 (true) if the operation was successful.
148 If an error occurs, the return value $? is set to 1 (false).