blob: b3dbdb8b2300b677fdf238785fab1916e01c6979 [file] [log] [blame]
Simon Glasscfc90102021-07-24 09:03:36 -06001.. SPDX-License-Identifier: GPL-2.0+
2
3Command-line Parsing
4====================
5
6The command line is available in U-Boot proper, enabled by CONFIG_CMDLINE which
7is on by default. It is not enabled in SPL.
8
9There are two different command-line parsers available with U-Boot:
10the old "simple" one, and the much more powerful "hush" shell:
11
12Simple command-line parser
13--------------------------
14
15This takes very little code space and offers only basic features:
16
17- supports environment variables (through setenv / saveenv commands)
18- several commands on one line, separated by ';'
19- variable substitution using "... ${name} ..." syntax
20- special characters ('$', ';') can be escaped by prefixing with '\',
21 for example::
22
23 setenv bootcmd bootm \${address}
24
25- You can also escape text by enclosing in single apostrophes, for example::
26
27 setenv addip 'setenv bootargs $bootargs ip=$ipaddr:$serverip:$gatewayip:$netmask:$hostname::off'
28
29Hush shell
30----------
31
32This is similar to Bourne shell, with control structures like:
33
34- `if`... `then` ... `else`... `fi`
35- `for`... `do` ... `done`
36- `while` ... `do` ... `done`
37- `until` ... `do` ... `done`
38
39Hush supports environment ("global") variables (through setenv / saveenv
40commands) and local shell variables (through standard shell syntax
41`name=value`); only environment variables can be used with the "run" command
42
43The Hush shell is enabled with `CONFIG_HUSH_PARSER`.
44
45General rules
46-------------
47
48#. If a command line (or an environment variable executed by a "run"
49 command) contains several commands separated by semicolon, and
50 one of these commands fails, then the remaining commands will be
51 executed anyway.
52
53#. If you execute several variables with one call to run (i. e.
54 calling run with a list of variables as arguments), any failing
55 command will cause "run" to terminate, i. e. the remaining
56 variables are not executed.