summaryrefslogtreecommitdiffstats
path: root/src/core/exec.c
Commit message (Collapse)AuthorAgeFilesLines
* [cmdline] Expand settings within each command-line token individuallyMichael Brown2011-03-281-35/+79
| | | | | | | | | | | Perform settings expansion after tokenisation, and only at the point of executing each command. This allows statements such as dhcp && echo ${net0/ip} to work correctly. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Allow ";" as an unconditional command separatorMichael Brown2011-03-281-0/+14
| | | | | | | | | | | | It is currently possible to construct a sequence of commands to be executed regardless of success or failure using "|| &&" as the command separator. (The "||" captures the failure case, the blank command converts it to a success case.) Allow ";" to be used as a more visually appealing (and space-efficient) alternative. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Allow "echo -n" to inhibit trailing newlineMichael Brown2011-03-271-3/+30
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Add generic concat_args() functionMichael Brown2011-03-071-6/+43
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [parseopt] Refer to online documentation for command helpMichael Brown2011-03-041-3/+2Star
| | | | | | | | | | The online documentation (e.g. http://ipxe.org/cmd/ifopen), though not yet complete, is far more comprehensive than could be provided within the iPXE binary. Save around 200 bytes (compressed) by removing the command descriptions from the interactive help, and instead referring users directly to the web page describing the relevant command. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Generalise expand_command() to expand_settings()Michael Brown2011-01-281-75/+1Star
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Match user expectations for &&, ||, goto, and exitMichael Brown2010-11-291-41/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The && and || operators should be left-associative, since that is how they are treated in most other languages (including C and Unix shell). For example, in the command: dhcp net0 && goto dhcp_ok || echo No DHCP on net0 if the "dhcp net0" fails then the "echo" should be executed. After an "exit" or a successful "goto", further commands on the same line should never be executed. For example: goto somewhere && echo This should never be printed exit 0 && echo This should never be printed exit 1 && echo This should never be printed An "exit" should cause the current shell or script to terminate and return the specified exit status to its caller. For example: chain test.ipxe && echo Success || echo Failure [in test.ipxe] #!ipxe exit 0 should echo "Success". Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Fix multi-layer variable expansion (again)Michael Brown2010-11-231-3/+3
| | | | | | | | | | | | | | Expansion of the (admittedly perverse) "aaa}bbb${ccc" will currently fail because expand_command() does not check that the closing "}" occurs later than the opening "${". Fix by ensuring that the most recent opening "${" is used to match against the first *subsequent* closing "}". Total cost of this change: -12 bytes, bringing the overall cost of this feature to -4 bytes. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Fix multi-layer variable expansionMichael Brown2010-11-221-8/+12
| | | | | | | | | | | | | Expansion of ${${foo}} will currently fail, because the first opening "${" will be incorrectly matched against the first closing "}", leading to an attempt to expand the variable "${foo". Fix by ensuring that the most recent opening "${" is used to match against the first closing "}". Total cost: 8 bytes. :) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Add "isset" commandMichael Brown2010-11-221-0/+35
| | | | | | | | | The "isset" command can be used to determine whether or not a setting is present. For example: isset ${net0/ip} || dhcp net0 # If we have no IP address, try DHCP Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow "exit" to exit a scriptMichael Brown2010-11-221-4/+57
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [cmdline] Add trivial logical operators to iPXE command linesMichael Brown2010-11-221-36/+115
| | | | | | | | | | | | | | | | | Make the "||" and "&&" operators available within iPXE commands. For example: dhcp net0 || set net0/ip 192.168.0.2 would attempt to acquire an IP address via DHCP, falling back to a static address if DHCP fails. As a side-effect, comments may now be appended to any line. For example: dhcp net0 || set net0/ip 192.168.0.2 # Try DHCP first, then static Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [build] Rename gPXE to iPXEMichael Brown2010-04-201-3/+3
| | | | | | | | | | | Access to the gpxe.org and etherboot.org domains and associated resources has been revoked by the registrant of the domain. Work around this problem by renaming project from gPXE to iPXE, and updating URLs to match. Also update README, LOG and COPYRIGHTS to remove obsolete information. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [script] Allow for DOS-style line endings in scriptsMichael Brown2009-06-031-2/+3
| | | | | | | | | | | | | | | Windows text editors such as Notepad tend to use CRLF line endings, which breaks gPXE's signature detection for script images. Since scripts are usually very small, they end up falling back to being detected as valid PXE executable images (since there are no signature checks for PXE executables). Executing text files as x86 machine code tends not to work well. Fix by allowing for any isspace() character to terminate the "#!gpxe" signature, and by ensuring that CR characters get stripped during command line parsing. Suggested-by: Shao Miller <Shao.Miller@yrdsb.edu.on.ca>
* [legal] Add a selection of FILE_LICENCE declarationsMichael Brown2009-05-181-0/+2
| | | | | Add FILE_LICENCE declarations to almost all files that make up the various standard builds of gPXE.
* [tables] Redefine methods for accessing linker tablesMichael Brown2009-03-131-6/+1Star
| | | | | | | | | | | | | | | Intel's C compiler (icc) chokes on the zero-length arrays that we currently use as part of the mechanism for accessing linker table entries. Abstract away the zero-length arrays, to make a port to icc easier. Introduce macros such as for_each_table_entry() to simplify the common case of iterating over all entries in a linker table. Represent table names as #defined string constants rather than unquoted literals; this avoids visual confusion between table names and C variable or type names, and also allows us to force a compilation error in the event of incorrect table names.
* [cmdline] Add setting expansion using ${...} syntaxMichael Brown2008-07-271-2/+96
| | | | | | | | | Allow settings to be expanded in arbitrary commands, such as kernel http://10.0.0.1/boot.php?uuid=${uuid} Also add the "echo" command, as being the easiest way to test this features.
* Use stdio.h instead of vsprintf.hMichael Brown2007-01-191-1/+1
|
* Ignore comment lines.Michael Brown2007-01-121-3/+5
| | | | Avoid returning errors for comments and empty lines.
* Add "name" field to struct device to allow human-readable hardware deviceMichael Brown2007-01-101-2/+4
| | | | | | | | | | | names. Add "dev" pointer in struct net_device to tie network interfaces back to a hardware device. Force natural alignment of data types in __table() macros. This seems to prevent gcc from taking the unilateral decision to occasionally increase their alignment (which screws up the table packing).
* Use common symbols to avoid dragging in getopt.o unless a getopt-usingMichael Brown2006-12-191-0/+4
| | | | command is linked in.
* Cope with system("").Michael Brown2006-12-081-6/+12
|
* D'oh d'oh d'oh d'oh d'oh d'oh d'oh d'oh d'ohMichael Brown2006-12-081-3/+9
|
* Added execv() and system().Michael Brown2006-12-081-0/+139