summaryrefslogtreecommitdiffstats
path: root/common/parser.c
Commit message (Collapse)AuthorAgeFilesLines
* treewide: add SPDX-License-Identifier for files without explicit licenseAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | Record GPL-2.0-only as license for all files lacking an explicit license statement. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: readline: fix possible buffer overflowsAhmad Fatoum2021-03-221-1/+1
| | | | | | | | Entering very long lines can crash the readline prompt due to missing NUL terminator. Make sure we don't exceed CONFIG_CBSIZE to avoid this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Shell: Handle aborting loops betterSascha Hauer2019-04-241-0/+1
| | | | | | | | | | | | | | | | | | It's easy to get stuck in an infinite loop in the hush shell: while true; do sleep 1; done The 'sleep' command will check for ctrl-c with the ctrlc() function. This will abort the sleep command. Hush then checks for ctrl-c again in the loop. The ctrl-c in the buffer has already been eaten by the sleep command, so the loop will continue. With this patch we remember the presence of a ctrl-c character in a variable instead of checking for a new character each time. The variable must be resetted explicitly by calling ctrlc_handled() which will be called by the shell in the outer loop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common/parser.c: s/%d/%zu/ when printing size_tAhmad Fatoum2018-12-051-2/+2
| | | | | Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common/parser.c: Do not treat zero return code as errorAndrey Smirnov2015-10-151-8/+7
| | | | | | | | | Run_command() would return zero to indicated success so treating it as error case would completely break command repetition logic, so change comparinson operator from "less or equal" to "less then" Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common/parser.c: Do not conflate error reporting disciplinesAndrey Smirnov2015-10-151-1/+2
| | | | | | | | | | | | Run_command() uses 0 to indicate success and negative values to indicate errors, whereas execute_command() uses 0 for success and positive integers to represent error codes. Conflating the two breaks the code that calls run_command and then checks for error code sign to detect problems, so avoid that by doing a very simple transformation on the result of execute_command Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* login: rework login mechanismSascha Hauer2015-08-281-0/+3
| | | | | | | | | | | | | | We used to have the login functionality in the /env/bin/init script. This is hard to review and it's too easy to break the login functionality with changes to this script. Move the places to ask for a password to C code where we have only a few places where we have to ask for a password. Mainly these are run_shell() and the menutree command. This patch introduces a login() function which will only return if the correct password has been entered. Following calls will return immediately without asking for a password again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix 'new blank line at EOF' formatting errorAntony Pavlov2015-07-021-1/+0
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* run_command: remove unused flag parameterSascha Hauer2014-03-071-4/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* process_escape_sequence: add support to \$?Jean-Christophe PLAGNIOL-VILLARD2013-09-181-0/+9
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix format specifiersSascha Hauer2013-01-271-3/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* parser: use debug macrosRobert Schwebel2010-11-011-28/+23
| | | | | Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* consolidate command calling in execute_commandSascha Hauer2009-10-191-18/+1
| | | | Signed-off-by: Sascha Hauer <sha@pengutronix.de>
* Remove part #ifdefed with #if (CONFIG_COMMANDS & CFG_CMD_BOOTD) which isMenon, Nishanth2008-05-121-17/+1
| | | | false everytime
* make simple parser compile againSascha Hauer2007-10-011-3/+1
|
* - teach hush to honour PATH variableSascha Hauer2007-09-241-1/+30
| | | | - remove common/main.c. This is now handled in the different shells.
* svn_rev_683Sascha Hauer2007-07-051-1/+3
| | | | more cleanups, fix compiler warnings
* svn_rev_412Sascha Hauer2007-07-051-15/+3
| | | | remove repeatable commands
* svn_rev_307Sascha Hauer2007-07-051-0/+302
some main.c cleanup: - move the parser used when hush is disabled to parser.c - move readline related functions to readline.c (with cmdline editing) and readline_simple.c (no cmdline editing)