summaryrefslogtreecommitdiffstats
path: root/common/cli_hush.c
Commit message (Collapse)AuthorAgeFilesLines
* cli: hush: Adjust 'run' command to run each line of the env varSimon Glass2014-10-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The run command treats each argument an an environment variable. It gets the value of each variable and executes it as a command. If an environment variable contains a newline and the hush cli is used, it is supposed to execute each line one after the other. Normally a newline signals to hush to exit - this is used in normal command line entry - after a command is entered we want to return to allow the user to enter the next one. But environment variables obviously need to execute to completion. Add a special case for the execution of environment variables which continues when a newline is seen, and add a few tests to check this behaviour. Note: it's not impossible that this may cause regressions in other areas. I can't think of a case but with any change of behaviour with limited test coverage there is always a risk. From what I can tell this behaviour has been around since at least U-Boot 2011.03, although this pre-dates sandbox and I have not tested it on real hardware. Reported-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
* common/cli_hush.c: remove unnecessary double bracesJeroen Hofstee2014-06-111-2/+2
| | | | | | | | | | Clang interpretes an if condition like "if ((a = b) == NULL) as it tries to assign a value in a statement. Hence if you do "if ((something)) it warns you that you might be confused. Hence drop the double braces for plane if statements. Simon Glass <sjg@chromium.org> Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
* Fix hush to give the correct return code for a simple commandSimon Glass2014-06-051-1/+3
| | | | | | | | | | | | | | | | | | | | When a simple command like 'false' is provided, hush should return the result of that command. However, hush only does this if the FLAG_EXIT_FROM_LOOP flag is provided. Without this flag, hush will happily execute the empty string command immediate after 'false' and then return a success code. This behaviour does not seem very useful, and requiring the flag also seems wrong, since it means that hush will execute only the first command in a sequence. Add a check for empty string and fall out of the loop in that case. That at least fixes the simple command case. This is a change in behaviour but it is unlikely that the old behaviour would be considered correct in any case. Reported-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net> Signed-off-by: Simon Glass <sjg@chromium.org>
* Rename bootretry functions and remove #ifdefsSimon Glass2014-05-291-6/+1
| | | | | | | Add a bootretry_ prefix to these two functions, and remove the need for the #ifdef around everything (it moves to the Makefile). Signed-off-by: Simon Glass <sjg@chromium.org>
* Move bootretry code into bootretry.c and clean upSimon Glass2014-05-291-0/+1
| | | | | | | This code is only used by one board, so it seems a shame to clutter up the readline code with it. Move it into its own file. Signed-off-by: Simon Glass <sjg@chromium.org>
* Add cli_ prefix to readline functionsSimon Glass2014-05-291-2/+2
| | | | | | This makes it clear where the code resides. Signed-off-by: Simon Glass <sjg@chromium.org>
* move CLI prototypes to cli.h and add commentsSimon Glass2014-05-291-0/+1
| | | | | | | Move the CLI prototypes from common.h to cli.h as part of an effort to reduce the size of common.h. Signed-off-by: Simon Glass <sjg@chromium.org>
* Rename hush to cli_hushSimon Glass2014-05-291-0/+3687
Hush is a command-line interpreter, so rename it to make that clearer. Signed-off-by: Simon Glass <sjg@chromium.org>
OpenPOWER on IntegriCloud