summaryrefslogtreecommitdiffstats
path: root/common/hush.c
Commit message (Collapse)AuthorAgeFilesLines
...
| * 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
|
* set last_return_code to rcode and not 1 or 0Sascha Hauer2007-09-271-1/+1
|
* pass file size from read_fileSascha Hauer2007-09-271-1/+1
|
* hush.c: use xrealloc instead of realloc to save some bytesSascha Hauer2007-09-261-2/+1
|
* hush.c: use xzalloc instead of xmalloc to save some bytesSascha Hauer2007-09-261-8/+1
|
* hush.c: Remove wrong free() of ctx->pipe->progs. After breaking outSascha Hauer2007-09-261-3/+0
| | | | | of the while loop ctx->pipe is invalid, so we cannot dereference ctx->pipe->progs.
* remove extern declaration of console_bufferSascha Hauer2007-09-261-1/+0
|
* fix indentionSascha Hauer2007-09-251-2/+3
|
* remove hack from hush which did the wrong thingSascha Hauer2007-09-251-5/+0
|
* add $# handling for hushSascha Hauer2007-09-251-0/+28
|
* remove debug printfSascha Hauer2007-09-241-1/+0
|
* remove u-boot command paramter flagSascha Hauer2007-09-241-19/+6
|