summaryrefslogtreecommitdiffstats
path: root/common/command.c
Commit message (Collapse)AuthorAgeFilesLines
* command: Use array of pointers to commandsSascha Hauer2019-10-141-4/+4
| | | | | | | | | | | | | | | | | We used to store the commands as a linker array. One problem with this is that on X86_64 for unknown reasons the linker uses a different struct alignment than the compiler, so when we use the linker to compose the array and the compiler to iterate over it we have to play tricks with manually adjusting the alignment. The other problem is that we declare the commands as const (and also put it in .rodata), but in fact we do not treat it as const: we put the commands onto a list which modifies the struct list_head list member of struct command. With this patch we no longer put the command themselves into an array, but instead create an array of pointers to the commands. This inherently solves the second issue as well. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: allow <cmd>_aliases[] to be constIan Abbott2017-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Commands with aliases define an array of alias strings such as: static const char *<cmd>_aliases[] = { "<alias1>", NULL}; Although the elements are of type `const char *`, the elements themselves are not `const`-qualified. If the array is declared as: static const char * const <cmd>_aliases[] = { "<alias1>", NULL}; then the compiler warns about const qualifiers being discarded. This is because the `aliases` member of `struct command` is declared as `const char *aliases;`. Change the declaration of the `aliases` member of `struct command` to `const char * const *aliases;` so that it can point to a `const` array of `const char *`. Also change the declaration of the `aliases` variable in `register_command()` to avoid unnecessary type casts. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common/command.c: Replace magic number with appropriate constantAndrey Smirnov2015-10-151-1/+1
| | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* command: allow runtime usageJean-Christophe PLAGNIOL-VILLARD2015-03-191-0/+2
| | | | | | | This will allow as example to list the currently supported digest. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: harmonize in-barebox documentationHolger Schurig2014-05-141-20/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does probably too much, but it's hard (and very cumbersome/time consuming) to break it out. What is does is this: * each command has one short description, e.g. "list MUX configuration" * made sure the short descriptions start lowercase * each command has one usage. That string contains just the options, e.g. "[-npn]". It's not part of the long help text. * that is, it doesn't say "[OPTIONS]" anymore, every usable option is listed by character in this (short) option string (the long description is in the long help text, as before) * help texts have been reworked, to make them - sometimes smaller - sometimes describe the options better - more often present themselves in a nicer format * all long help texts are now created with BUSYBOX_CMD_HELP_ macros, no more 'static const __maybe_unused char cmd_foobar_help[]' * made sure the long help texts starts uppercase * because cmdtp->name and cmdtp->opts together provide the new usage, all "Usage: foobar" texts have been removed from the long help texts * BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this is nicer in the source code * BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself * made sure no line gets longer than 77 characters * delibertely renamed cmdtp->usage, so that we can get compile-time errors (e.g. in out-of-tree modules that use register_command() * the 'help' command can now always emit the usage, even without compiled long help texts * 'help -v' gives a list of commands with their short description, this is similar like the old "help" command before my patchset * 'help -a' gives out help of all commands Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* command: return 1 on unknown commandSascha Hauer2012-11-011-1/+1
| | | | | | | | hush now prints the error value if a command returns a value < 0, so do not return -1 (EPERM) when we encounter an unknown command. Instead, return 1 so that hush is quiet. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hush: Make exit a shell builtinSascha Hauer2012-08-101-20/+0
| | | | | | | | | | | | | | | | | | | | 'exit' used to do its job by returning value < 0. This is a sign for hush that 'exit' is executed. This has problems: - Often commands accidently return a negative value. This causes the shell to exit. - execute_binfmt returns a negative value when it does not find a binary to execute. This again causes the shell to exit. Returning a negative error value seems to be the right thing to do, but catching this in the shell would mean that the exit command does not work anymore. - if called without arguments exit is supposed to return the code of the last command. As a command exit has no access to this code. This patch changes exit to be a builtin and also fixes the last return code problem. While at it, update the help text. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* command: add missing EXPORT_SYMBOL for find_cmdJean-Christophe PLAGNIOL-VILLARD2012-07-251-0/+1
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: remove struct command pointer from commandsSascha Hauer2012-02-271-2/+2
| | | | | | This is unused in all commands and thus can be removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* command: do not allow abbreviated commands anymoreSascha Hauer2012-02-271-19/+3
| | | | | | | | | | | | abbreviated commands are derived from U-Boot and are only partly useful. Noone expects from a shell to support this, also we have tab completion. They also have some funny side effects. For example we have a 'time' command. If this command is not compiled in, the time command is interpreted as an abbreviated version of the 'timeout' command. So remove support for abbreviated commands and safe the binary space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* getopt: save and restore contextSascha Hauer2012-02-271-4/+8
| | | | | | | | | | | | 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>
* move version_string to seperate fileSascha Hauer2011-04-111-4/+0
| | | | | | | | | In a noninteractive environment barebox will be compiled without command support. So move version_string to a seperate file which is compiled unconditionally. Also, display the banner when the simple console support is used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move utsrelease.h to include/generated/ instead of include/linuxJean-Christophe PLAGNIOL-VILLARD2010-09-171-1/+1
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* remove typedef cmd_tbl_t and replace it with struct commandSascha Hauer2010-02-011-13/+13
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rename U-Boot-v2 project to bareboxSascha Hauer2009-12-151-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove deadlock messageJuergen Beisert2009-11-191-0/+4
| | | | | | | | | | | | | | | | Any wrong or unknown command will result into the output: Unknown command '<some text>' - try 'help' If the command 'help' is disabled, this will end up in: Unknown command 'help' - try 'help' which is for blondes. Suppress the "try 'help'" for the case the 'help' command is disabled. Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* list: remove duplicated list.hSascha Hauer2009-11-031-1/+1
| | | | | | | | We accidently have two list implementations in the tree: include/list.h and include/linux/list.h. This patch moves the latter (newer one) to include/linux/list.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: remove maxargsSascha Hauer2009-10-191-6/+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>
* call getopt_reset only onceSascha Hauer2009-10-191-0/+3
| | | | | | | instead of calling getopt_reset in each command, call it only once before calling the command. Signed-off-by: Sascha Hauer <sha@pengutronix.de>
* commands: add defines for command errors/successSascha Hauer2009-10-191-1/+7
| | | | | | | | This allows us to return COMMAND_ERROR_USAGE for a failed command which will then print the usage, a very common case for commands. Signed-off-by: Sascha Hauer <sha@pengutronix.de>
* consolidate command calling in execute_commandSascha Hauer2009-10-191-0/+19
| | | | Signed-off-by: Sascha Hauer <sha@pengutronix.de>
* move several commands into extra filesSascha Hauer2008-08-131-79/+0
| | | | | | move false, true, help, insmod, lsmod, version into extra files Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* console: add a simple console for saving spaceSascha Hauer2008-08-011-1/+4
| | | | | | | Add a simple console layer which is not able to handle multiple consoles for those who don't need it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Subject: [PATCH] [general] Fixed constant strings in data section issueSascha Hauer2008-04-041-6/+6
| | | | | | | | 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>
* implement TAB completionSascha Hauer2008-03-011-285/+1
|
* - Insert commands sorted into the command list. This is usefulsascha2007-10-191-39/+36
| | | | | for commands added via modules. - Let command aliases show up in help text
* move readline command to a file of its ownsascha2007-10-191-31/+0
|
* Collect all commands in a linked list. This makes it easier to handleSascha Hauer2007-10-111-41/+43
| | | | dynamically registered commands.
* export functionsSascha Hauer2007-10-041-3/+4
|
* Add register_command() to register a command in runtime. ThisSascha Hauer2007-10-011-1/+46
| | | | | is only needed when modules are enabled, so the change is inside "#ifdef CONFIG_MODULE"
* declare lots of functions staticSascha Hauer2007-09-281-11/+6
|
* remove u-boot command paramter flagSascha Hauer2007-09-241-6/+6
|
* - teach hush to honour PATH variableSascha Hauer2007-09-241-1/+1
| | | | - remove common/main.c. This is now handled in the different shells.
* - putc is now putchar for better standard conformitySascha Hauer2007-09-211-5/+5
| | | | - make printf return int
* svn_rev_701Sascha Hauer2007-07-051-133/+0
| | | | move do_test to own file and reimplement
* svn_rev_571Sascha Hauer2007-07-051-1/+3
| | | | add line break to help messages
* svn_rev_481Sascha Hauer2007-07-051-2/+2
| | | | make more char * const, fix compiler warnings
* svn_rev_462Sascha Hauer2007-07-051-77/+60
| | | | | | | - Add help texts for many commands. - Let the linker sort the command table. - Add support for multiple argmuments in several commands (mkdir, rmdir, rm, cat)
* svn_rev_459Sascha Hauer2007-07-051-1/+1
|
* svn_rev_420Sascha Hauer2007-07-051-57/+66
| | | | | | | | | | | - do more POSIX: - use DIR instead of struct dirent - use (struct dirent)->d_name instead of (struct dirent)->name - switch to a new layout for U_BOOT_CMD: - use C99 initializers to be able to add more fields to the command struct - add aliases for commands (needed mainly for help -> ? and test -> [ - This is not done for all commands yet, but the compiler will tell you ;)
* svn_rev_375Sascha Hauer2007-07-051-32/+51
| | | | add readline, true, false commands
* svn_rev_316Sascha Hauer2007-07-051-1/+4
| | | | make help command removable
* svn_rev_207Sascha Hauer2007-07-051-13/+13
| | | | move several config options to kconfig
* svn_rev_135Sascha Hauer2007-07-051-2/+2
| | | | CFG_CMD_ECHO -> CONFIG_CMD_ECHO
* svn_rev_003Sascha Hauer2007-07-051-11/+0
| | | | remove all #if 0 and #if 1
* Adjust "echo" as a default commandWolfgang Denk2006-03-121-0/+4
| | | | Patch by Sam Song, 19 Jun 2005
* * Patches by Robert Whaley, 29 Nov 2004:wdenk2005-04-061-2/+2
| | | | | | | | | | | | - update the pxa-regs.h file for PXA27x chips - add PXA27x based ADSVIX board - add support for MMC on PXA27x processors * Patch by Andrew E. Mileski, 28 Nov 2004: Fix PPC4xx SPD SDRAM detection bug * Patch by Hiroshi Ito, 26 Nov 2004: Fix logic of "test -z" and "test -n" commands
* * Cleanup, minor fixeswdenk2004-04-181-2/+2
| | | | | | | | | * Patch by Rune Torgersen, 16 Apr 2004: LBA48 fixes * Patches by Pantelis Antoniou, 16 Apr 2004: - Fix some compile problems; add "once" functionality for the netretry variable
* Patches by Pantelis Antoniou, 16 Apr 2004:wdenk2004-04-181-0/+153
| | | | | | | | | | | | | | | | | - add support for a new version of an Intracom board and fix various other things on others. - add verify support to the crc32 command (define CONFIG_CRC32_VERIFY to enable it) - fix FEC driver for MPC8xx systems: 1. fix compilation problems for boards that use dynamic allocation of DPRAM 2. shut down FEC after network transfers - HUSH parser fixes: 1. A new test command was added. This is a simplified version of the one in the bourne shell. 2. A new exit command was added which terminates the current executing script. 3. Fixed handing of $? (exit code of last executed command)