summaryrefslogtreecommitdiffstats
path: root/common/hush.c
Commit message (Collapse)AuthorAgeFilesLines
...
* run_shell: run again on ctrl-cSascha Hauer2012-05-211-4/+6
| | | | | | | | We can start a new interactive shell now using the 'sh' command on the command line. This shell exits on ctrl-c though. Add a loop around it to continue instead of exiting. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'next'Sascha Hauer2012-05-031-316/+486
|\ | | | | | | | | | | | | Conflicts: common/hush.c Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: allow to run interactive shell in do_shSascha Hauer2012-04-301-1/+1
| | | | | | | | | | | | | | This allows to call 'sh' in scripts without arguments in which case an interactive shell will be started. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: Fix globbingSascha Hauer2012-04-301-48/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | hush has a long standing and anoying glob bug. hush expands wildcards during parsing of the script or command stream. When the command stream begins to execute the wildcards are already expanded which leads to: mkdir /tmp cd /tmp mkdir foo; ls * ls: *: No such file or directory To fix this expand wildcards right before executing the command. Since 'for' loops are not executed in commands, we have to keep the old behaviour in here so that 'for i in *' still works. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: pass GLOB_NOCHECK to globSascha Hauer2012-04-301-6/+1
| | | | | | | | | | | | | | By doing so glob will not return GLOB_NOMATCH anymore but instead just does what fake_glob would do. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: simplify globhackSascha Hauer2012-04-301-31/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | hush used to escape '*' '[' '?' during parsing because the quotes got removed in the first parsing loop. globhack is used to remove these escapes again for glob. Since we now keep the quotes until the end of parsing and we no longer escape glob wildcards, we do no longer have to remove any quotes. With this globhack can be much simpler. While at it, change the prototype to match the one from glob() and rename the function to fake_glob, because that's what it is: it just copies the input string into the output struct without actually globbing. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: remove quotes at end of processingSascha Hauer2012-04-301-23/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | hush removes the quotes from strings too early. This leads to some bugs. When hush executes echo "hello sascha" it correctly results in: argv[0] = "echo" argv[1] = "hello sascha" However, the following behaves incorrect: a="hello sascha" echo "$a" results in: argv[0] = "echo" argv[1] = "hello" argv[2] = "sascha" This is because hush removes the quotes and inserts variable values in a single loop, so echo "$a" becomes: echo hello sascha after the loop. Instead, keep the quotes until all variables are inserted and remove them at the end. This also fixes that echo \" resulted in \" instead of ". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: run_pipe_real: bail out early to safe an indention levelSascha Hauer2012-04-301-51/+47
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: run_pipe_real must have num_progs == 1Sascha Hauer2012-04-301-7/+9
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: remove bogus 'else'Sascha Hauer2012-04-301-1/+3
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: cleanup coding styleSascha Hauer2012-04-301-109/+221
| | | | | | | | | | | | | | | | | | General coding style cleanup - add some blank lines - add whitespaces on on both sides of operators Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: safe an indention level by continueing a loopSascha Hauer2012-04-301-66/+69
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * hush: safe indention level by continueing a loopSascha Hauer2012-04-301-79/+81
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * Introduce binfmt supportJean-Christophe PLAGNIOL-VILLARD2012-04-181-12/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | This will allow to execute any file and detect it's type to handle it. This will allow to use shell for bootp bootfile or dfu. You can register multiple hook for the same filetype. They will be execute in the invert order of register. If a hook does not handle the file you just return -ERESTARTNOHAND; This is only available with hush parser. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* | hush: bail out of scripts on syntax errorSascha Hauer2012-05-021-1/+3
|/ | | | | | | | | | | | | | On a systax error we have to bail out of the shell instead of setting inp->p to NULL and crash barebox with a NULL pointer deref. This only happened in scripts. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> This fixes the problem I had (i.e. a boot loop caused by a stray fi in /env/bin/init). Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* hush source: expand $PATHSascha Hauer2012-03-181-1/+16
| | | | | | | | The behaviour of other shells suggest that with source or '.' the path should be resolved using the PATH environment variable. Do the same in barebox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: remove struct command pointer from commandsSascha Hauer2012-02-271-4/+4
| | | | | | This is unused in all commands and thus can be removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* getopt: save and restore contextSascha Hauer2012-02-271-5/+10
| | | | | | | | | | | | execute_command is the single point where commands are executed and thus a new getopt context is needed. currently we call getopt_reset here to reset the context. This breaks though when a command tries to run a command itself by calling execute_command or run_command. In this case we have to store the context and restore it afterwards. The same is necessary in builtin_getopt. Currently noone does this so this one shouldn't fix a bug, but merely allows us to do such things later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: Add magicvarsSascha Hauer2011-11-291-0/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move simple_itoa to libbb so that others can use itSascha Hauer2011-04-121-14/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: sparse fixesSascha Hauer2010-10-211-5/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: implement getopt builtinSascha Hauer2010-10-081-2/+108
| | | | | | | | | | | | | | | | | | | | Positional parameters are not nice, so implement a getopt function. This has to be done as a builtin because otherwise we have no access to the parents argc/argv. getopt works as expected, here is a little example: while getopt "hs:" OPT do if [ $OPT = h ]; then echo "usage" exit 1 else echo "scr: opt: $OPT optarg: $OPTARG" fi done Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: fix nasty memory leak in hushSascha Hauer2010-10-081-0/+1
| | | | | | | | | Fix memory leak in globbing part of hush. a simple '[' on the command line was enough to trigger it. We must call globfree() before setting the glob structure to zero. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: pass context around in shellSascha Hauer2010-10-081-9/+9
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: allow fancy promptsSascha Hauer2010-03-301-4/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: only remove backslashes introduced from globSascha Hauer2010-03-301-2/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: Fix return code when calling 'exit' inside loopsSascha Hauer2010-03-301-11/+3
| | | | | | | | | | | | | | | | | | | | v2: Do not exit from all scripts but only the current one This fixes the case: barebox:/ cat /test if [ 0 = 0 ]; then exit 1 fi barebox:/ /test barebox:/ echo $? 0 barebox:/ Also, remove code to not allow exit from main shell. The for(;;) loop in common/startup.c will bring us back anyway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove typedef cmd_tbl_t and replace it with struct commandSascha Hauer2010-02-011-3/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename U-Boot-v2 project to bareboxSascha Hauer2009-12-151-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | This has been done with the following script: find -path ./.git -prune -o -type f -print0 | xargs -0 -r sed -i \ -e 's/u2boot/barebox/g' \ -e 's/U2Boot/barebox/g' \ -e 's/U-boot V2/barebox/g' \ -e 's/u-boot v2/barebox/g' \ -e 's/U-Boot V2/barebox/g' \ -e 's/U-Boot-v2/barebox/g' \ -e 's/U_BOOT/BAREBOX/g' \ -e 's/UBOOT/BAREBOX/g' \ -e 's/uboot/barebox/g' \ -e 's/u-boot/barebox/g' \ -e 's/u_boot/barebox/g' \ -e 's/U-Boot/barebox/g' \ -e 's/U-boot/barebox/g' \ -e 's/U-BOOT/barebox/g' find -path ./.git -prune -o \( -name "*u-boot*" -o -name "*uboot*" -o -name "*u_boot*" \) -print0 | \ xargs -0 -r rename 's/u[-_]?boot/barebox/' It needs some manual fixup following in the next patch Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: remove include/hush.hSascha Hauer2009-10-221-1/+4
| | | | | | | Everything in include/hush.h is only used in hush.c, so remove the header file. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: remove maxargsSascha Hauer2009-10-191-2/+0
| | | | | | | No need to check for maximum argument counts. The commands are safe to be called with more arguments, so lets safe some bytes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: return COMMAND_ERROR_USAGESascha Hauer2009-10-191-8/+4
| | | | | | | instead of calling u_boot_cmd_usage in each command to safe space. Signed-off-by: Sascha Hauer <sha@pengutronix.de>
* consolidate command calling in execute_commandSascha Hauer2009-10-191-17/+1
| | | | Signed-off-by: Sascha Hauer <sha@pengutronix.de>
* hush: pass return code from exit commandSascha Hauer2009-09-251-0/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: Only run list if it's not emptySascha Hauer2009-09-251-1/+6
| | | | | | Running empty lists lead to the wrong return status Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: Fix quotingSascha Hauer2008-11-101-1/+1
| | | | | | | | | | | | | | | This patch removes adding of an additional \ when doing echo "\"" which gives \" instead of just " I checked in latest busybox hush and this code is still present there, but it behaves correctly in busybox due to some other code pathes I didn't investigate. If this change has any unwanted side effects feel free to flame on me Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: fix compiler warningSascha Hauer2008-08-261-2/+6
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Subject: [PATCH] [general] Fixed constant strings in data section issueSascha Hauer2008-04-041-4/+7
| | | | | | | | For practical reasons I changed all string literals assumed to be constant to reside in .rodata subsection at end of .text section. Signed-off-by: Carsten Schlote <schlote@vahanus.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* replace debug_printf with debug in hush.cSascha Hauer2008-03-091-42/+35
|
* add globbing supportSascha Hauer2008-03-091-27/+103
|
* adding various dokuJuergen Beisert2007-11-081-7/+7
|
* shell info addedJuergen Beisert2007-10-191-20/+24
|
* hush doc addedJuergen Beisert2007-10-191-36/+73
|
* hush.c: split high-density "if(x) something"; into two linesSascha Hauer2007-10-011-27/+57
|
* hush.c: get_local_var() is used only once, put it into the functionSascha Hauer2007-10-011-18/+3
| | | | where it is called
* fix indention in hush.cSascha Hauer2007-10-011-3/+3
|
* remove comment about glob in hush.c. We do not use globSascha Hauer2007-10-011-8/+0
|
* fix indention in hush.cSascha Hauer2007-10-011-64/+66
|
* fix indention in hush.cSascha Hauer2007-10-011-1/+3
|
* fix indention in hush.cSascha Hauer2007-10-011-25/+25
|