9
0
Fork 0
Commit Graph

72 Commits

Author SHA1 Message Date
Sascha Hauer 33d1cc4bf2 commands: remove struct command pointer from commands
This is unused in all commands and thus can be removed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-02-27 20:28:07 +01:00
Sascha Hauer aed0e6ba03 getopt: save and restore context
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>
2012-02-27 19:53:47 +01:00
Sascha Hauer 76dca8279e hush: Add magicvars
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-11-29 20:51:32 +01:00
Sascha Hauer 8e8c61e786 move simple_itoa to libbb so that others can use it
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-04-12 09:54:56 +02:00
Sascha Hauer 345d93eb7c hush: sparse fixes
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-10-21 22:21:24 +02:00
Sascha Hauer 914e2f8f7f hush: implement getopt builtin
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>
2010-10-08 15:30:43 +02:00
Sascha Hauer 97b2a33c50 hush: fix nasty memory leak in hush
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>
2010-10-08 14:18:37 +02:00
Sascha Hauer dff63d2399 hush: pass context around in shell
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-10-08 11:40:09 +02:00
Sascha Hauer 6eb741a2e1 hush: allow fancy prompts
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-03-30 14:15:03 +02:00
Sascha Hauer 66e4e9242b hush: only remove backslashes introduced from glob
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-03-30 14:15:03 +02:00
Sascha Hauer 2477fb12e9 hush: Fix return code when calling 'exit' inside loops
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>
2010-03-30 12:51:44 +02:00
Sascha Hauer 922bb41a47 remove typedef cmd_tbl_t and replace it with struct command
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-02-01 17:25:32 +01:00
Sascha Hauer a3ffa97f40 rename U-Boot-v2 project to barebox
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>
2009-12-15 10:18:30 +01:00
Sascha Hauer 14eb082606 hush: remove include/hush.h
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>
2009-10-22 11:17:25 +02:00
Sascha Hauer 420a3173f0 commands: remove maxargs
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>
2009-10-19 16:18:33 +02:00
Sascha Hauer 87e01f28cc commands: return COMMAND_ERROR_USAGE
instead of calling u_boot_cmd_usage in each command to safe
space.

Signed-off-by: Sascha Hauer <sha@pengutronix.de>
2009-10-19 10:18:52 +02:00
Sascha Hauer ef7ff70ca4 consolidate command calling in execute_command
Signed-off-by: Sascha Hauer <sha@pengutronix.de>
2009-10-19 10:18:51 +02:00
Sascha Hauer d81251712c hush: pass return code from exit command
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-09-25 13:34:27 +02:00
Sascha Hauer 4596d2b6f9 hush: Only run list if it's not empty
Running empty lists lead to the wrong return status

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2009-09-25 13:34:22 +02:00
Sascha Hauer 8d36379153 hush: Fix quoting
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>
2008-11-10 17:54:15 +01:00
Sascha Hauer 2b729e45b4 hush: fix compiler warning
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2008-08-26 11:40:51 +02:00
Sascha Hauer 50cc8c5412 Subject: [PATCH] [general] Fixed constant strings in data section issue
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>
2008-04-04 14:45:04 +02:00
Sascha Hauer f0aa2fcd09 replace debug_printf with debug in hush.c 2008-03-09 23:06:20 +01:00
Sascha Hauer 187847b2b4 add globbing support 2008-03-09 22:35:38 +01:00
Juergen Beisert 8fe25ecf12 adding various doku 2007-11-08 12:01:52 +01:00
Juergen Beisert 30e09b83d5 shell info added 2007-10-19 21:35:46 +02:00
Juergen Beisert 44630acd4a hush doc added 2007-10-19 21:07:43 +02:00
Sascha Hauer 400b0abab2 hush.c: split high-density "if(x) something"; into two lines 2007-10-01 23:35:33 +02:00
Sascha Hauer ee5847aac7 hush.c: get_local_var() is used only once, put it into the function
where it is called
2007-10-01 23:28:00 +02:00
Sascha Hauer c1ab45e56d fix indention in hush.c 2007-10-01 23:19:18 +02:00
Sascha Hauer a14c000d59 remove comment about glob in hush.c. We do not use glob 2007-10-01 23:17:27 +02:00
Sascha Hauer 53d327d834 fix indention in hush.c 2007-10-01 23:15:52 +02:00
Sascha Hauer f4f3479f13 fix indention in hush.c 2007-10-01 23:13:21 +02:00
Sascha Hauer 67c7e6eb6f fix indention in hush.c 2007-10-01 23:12:34 +02:00
Sascha Hauer 27bf8f1dea set last_return_code to rcode and not 1 or 0 2007-09-27 17:10:14 +02:00
Sascha Hauer 79ed00ba92 pass file size from read_file 2007-09-27 16:33:35 +02:00
Sascha Hauer 5efc6836b7 hush.c: use xrealloc instead of realloc to save some bytes 2007-09-26 13:57:18 +02:00
Sascha Hauer fb441a11a0 hush.c: use xzalloc instead of xmalloc to save some bytes 2007-09-26 13:55:01 +02:00
Sascha Hauer 00c65e44ca hush.c: Remove wrong free() of ctx->pipe->progs. After breaking out
of the while loop ctx->pipe is invalid, so we cannot dereference
	ctx->pipe->progs.
2007-09-26 13:53:17 +02:00
Sascha Hauer 8f1559034a remove extern declaration of console_buffer 2007-09-26 13:50:55 +02:00
Sascha Hauer 97cf2a9805 fix indention 2007-09-25 13:47:47 +02:00
Sascha Hauer 21281ac59a remove hack from hush which did the wrong thing 2007-09-25 13:47:15 +02:00
Sascha Hauer 603ccc2378 add $# handling for hush 2007-09-25 13:42:33 +02:00
Sascha Hauer ddfa0c174e remove debug printf 2007-09-24 16:59:07 +02:00
Sascha Hauer 3cbc5c5c12 remove u-boot command paramter flag 2007-09-24 12:31:08 +02:00
Sascha Hauer b0615cc909 - add 'source' command
- add help text for 'source' and 'sh'
2007-09-24 12:06:52 +02:00
Sascha Hauer 14b5c2a647 - teach hush to honour PATH variable
- remove common/main.c. This is now handled in the different shells.
2007-09-24 01:40:06 +02:00
Sascha Hauer 0aab147904 fix indention 2007-09-23 23:35:32 +02:00
Sascha Hauer ecc1ee6602 allow arguments to be passed to scripts 2007-09-23 23:26:31 +02:00
Sascha Hauer a7f5dd903e unifdef __U_BOOT__ in hush.c 2007-09-22 18:08:18 +02:00