u-boot/common
Wolfgang Denk 855f18ea0e setexpr: add regex substring matching and substitution
Add "setexpr name gsub r s [t]" and "setexpr name sub r s [t]"
commands which implement substring matching for the regular
expression <r> in the string <t>, and substitution of the string <s>.
The result is assigned to the environment variable <name>.  If <t> is
not supplied, the previous value of <name> is used instead.  "gsub"
performs global substitution, while "sub" will replace only the first
substring.

Both commands are closely modeled after the gawk functions with the
same names.

Examples:

- Generate broadcast address by substituting the last two numbers of
  the IP address by "255.255":

  	=> print ipaddr
	ipaddr=192.168.1.104
	=> setexpr broadcast sub "(.*\\.).*\\..*" "\\1255.255" $ipaddr
	broadcast=192.168.255.255

- Depending on keyboard configuration (German vs. US keyboard) a
  barcode scanner may initialize the MAC address as C0:E5:4E:02:06:DC
  or as C0>E5>4E>02>06>DC.  Make sure we always have a correct value:

	=> print ethaddr
	ethaddr=C0>E5>4E>02>06>DC
	=> setexpr ethaddr gsub > :
	ethaddr=C0:E5:4E:02:06:DC

- Do the same, but substitute one step at a time in a loop until no
  futher matches:

	=> setenv ethaddr C0>E5>4E>02>06>DC
	=> while setexpr ethaddr sub > :
	> do
	> echo -----
	> done
	ethaddr=C0:E5>4E>02>06>DC
	-----
	ethaddr=C0:E5:4E>02>06>DC
	-----
	ethaddr=C0:E5:4E:02>06>DC
	-----
	ethaddr=C0:E5:4E:02:06>DC
	-----
	ethaddr=C0:E5:4E:02:06:DC
	-----
	C0:E5:4E:02:06:DC: No match
	=> print ethaddr
	ethaddr=C0:E5:4E:02:06:DC

etc.

To enable this feature, the CONFIG_REGEX option has to be defined in
the board config file.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2013-05-01 16:24:01 -04:00
..
spl SPL: ONENAND: Support SPL to boot u-boot from OneNAND. 2013-03-11 11:05:49 -04:00
bedbug.c Consolidate bool type 2013-04-01 16:33:52 -04:00
board_f.c sandbox: Add CONFIG_OF_HOSTFILE to read FDT from host file 2013-05-01 11:17:21 -04:00
board_r.c sandbox: Switch over to generic board 2013-05-01 11:17:21 -04:00
bootstage.c bootstage: Add feature to stash/unstash bootstage info 2012-10-03 00:52:40 +02:00
bouncebuf.c common: rework bouncebuf implementation 2012-11-27 17:26:48 -06:00
cmd_ambapp.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_bdinfo.c Merge branch 'master' of git://www.denx.de/git/u-boot-microblaze 2013-02-04 09:14:22 -05:00
cmd_bedbug.c Consolidate bool type 2013-04-01 16:33:52 -04:00
cmd_bmp.c video: Provide an API to access video parameters 2012-11-06 22:57:32 +01:00
cmd_boot.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_bootldr.c Blackfin: bootldr: use common defines 2011-04-08 00:44:27 -04:00
cmd_bootm.c image: Add support for Plan 9 2013-03-27 15:30:11 -04:00
cmd_bootmenu.c New command bootmenu: ANSI terminal boot menu support 2013-03-29 09:35:34 +01:00
cmd_bootstage.c bootstage: Add bootstage command 2012-10-03 00:52:44 +02:00
cmd_cache.c Cleanup cache command prints 2012-10-03 16:01:22 -07:00
cmd_cbfs.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_console.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_cplbinfo.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_cramfs.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_dataflash_mmc_mux.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_date.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_dcr.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_dfu.c dfu: Fix crash when wrong number of arguments given 2013-03-16 21:12:01 +01:00
cmd_diag.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_disk.c disk: get_device_and_partition() "auto" partition and cleanup 2012-09-25 14:58:48 -07:00
cmd_display.c led_display: split led display support into generic and hw-dependent parts 2010-10-12 22:44:33 +02:00
cmd_dtt.c TMU: Add TMU support in dtt command 2013-03-12 17:06:22 +09:00
cmd_echo.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_eeprom.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_elf.c cmd_elf: Fix broken bootvx command 2013-02-20 08:52:29 -05:00
cmd_exit.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_ext2.c fs: rename fsload command to load 2012-11-04 11:00:34 -07:00
cmd_ext4.c cmd_ext4: BREAK and correct ext4write parameter order 2013-03-27 15:30:11 -04:00
cmd_fat.c cmd_fat.c: Note in fatread help about alignment requirements 2013-03-12 12:43:31 -04:00
cmd_fdc.c Consolidate bool type 2013-04-01 16:33:52 -04:00
cmd_fdos.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_fdt.c sandbox: fdt: Support fdt command for sandbox 2013-05-01 11:17:21 -04:00
cmd_fitupd.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_flash.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_fpga.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_fs.c fs: rename fsload command to load 2012-11-04 11:00:34 -07:00
cmd_gettime.c Add gettime command 2012-12-11 13:17:33 -07:00
cmd_gpio.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_gpt.c gpt: fix partion size limit 2013-02-20 08:52:41 -05:00
cmd_hash.c hash: Use lower case for hash algorithm names 2013-02-28 19:49:13 -08:00
cmd_help.c Refactor linker-generated arrays 2013-03-12 23:28:40 +01:00
cmd_i2c.c edid: Add I2C command for printing the EDID 2012-12-11 13:17:35 -07:00
cmd_ide.c ide: Correct function signatures for ide_read/write() 2012-11-02 15:20:43 -07:00
cmd_immap.c ppc: Move brg_clk to arch_global_data 2013-02-01 15:42:45 -05:00
cmd_ini.c Improve license declaration for cmd_ini.h 2012-10-05 11:07:42 -07:00
cmd_io.c Add console command to access io space registers 2012-12-11 13:17:35 -07:00
cmd_irq.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_itest.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_jffs2.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_ldrinfo.c Blackfin: ldrinfo: new command 2011-04-08 00:44:27 -04:00
cmd_led.c led: Use STATUS_LED_ON and STATUS_LED_OFF when calling __led_set 2013-03-07 17:22:57 +01:00
cmd_license.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_load.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_log.c cmd_log: print log->v2.con value in the "log info" command 2012-03-30 22:32:50 +02:00
cmd_mac.c cmd_mac: fix help for 'mac read' 2011-07-28 16:41:06 +02:00
cmd_md5sum.c Add parameter to md5sum to save the md5 sum 2012-10-03 16:01:22 -07:00
cmd_mdio.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_mem.c cmd_mem.c: Fix warning when CONFIG_CMD_MEMTEST is not set 2013-03-12 12:43:31 -04:00
cmd_mfsl.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mii.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_misc.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_mmc_spi.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_mmc.c mmc: support the correct card version for eMMC 2013-04-17 10:58:51 -04:00
cmd_mp.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_mtdparts.c mtd: Make mtdparts work with pre-reloc env 2013-04-11 15:52:54 -04:00
cmd_nand.c cmd_nand.c: Fix CONFIG_CMD_NAND_YAFFS 2013-04-10 15:22:24 +02:00
cmd_net.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_nvedit.c "env grep" - add support for regular expression matches 2013-05-01 16:24:00 -04:00
cmd_onenand.c linux/compat.h: rename from linux/mtd/compat.h 2012-04-30 16:54:51 +02:00
cmd_otp.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_part.c cmd_part: don't print cmd name twice in help 2013-03-11 17:00:28 -04:00
cmd_pci.c common/cmd_*.c: sparse fixes 2012-11-04 11:00:35 -07:00
cmd_pcmcia.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_portio.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_pxe.c menu: Add support for user defined item choice function 2013-03-29 09:35:33 +01:00
cmd_read.c Add a command to read raw blocks from a partition 2012-12-11 13:17:33 -07:00
cmd_reginfo.c blackfin: bf60x: Port blackfin core architecture code to boot on bf60x. 2013-03-04 13:42:06 +08:00
cmd_reiser.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_sandbox.c sandbox: fs: Add support for saving files to host filesystem 2013-05-01 11:17:21 -04:00
cmd_sata.c common: cmd_sata: Fix usage text for 'sata init' 2013-02-23 11:18:24 +01:00
cmd_scsi.c Consolidate bool type 2013-04-01 16:33:52 -04:00
cmd_setexpr.c setexpr: add regex substring matching and substitution 2013-05-01 16:24:01 -04:00
cmd_sf.c cmd_sf: include header file common.h before div64.h 2013-04-08 12:00:51 -04:00
cmd_sha1sum.c hash: Add a flag to support saving hashes in the environment 2013-02-28 19:09:23 -08:00
cmd_sound.c Sound: Add FDT support to CMD. 2013-01-08 10:54:33 +09:00
cmd_source.c sandbox: Support 'source' command 2013-05-01 11:17:21 -04:00
cmd_spi.c cmd_spi: remove superfluous semicolon 2012-08-09 20:41:32 -04:00
cmd_spibootldr.c various cmd_* files: fixed layout a little bit 2010-08-09 01:07:37 +02:00
cmd_spl.c SPL: Change description for spl command 2013-03-01 12:01:32 -05:00
cmd_strings.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_terminal.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
cmd_test.c common/cmd_test: Avoid macro expansion 2013-04-08 12:00:51 -04:00
cmd_time.c cmd_time: merge run_command_and_time_it with cmd_process 2013-02-04 09:14:02 -05:00
cmd_tpm.c tpm: Add TPM command library 2013-04-12 14:13:13 -07:00
cmd_tsi148.c common: tsi148 - fix gcc 4.6 compiler warning 2011-11-16 21:42:17 +01:00
cmd_ubi.c ubi: ubifs: Turn off verbose prints 2013-04-11 15:52:54 -04:00
cmd_ubifs.c Convert cmd_usage() calls in common to use a return value 2012-03-06 21:09:46 +01:00
cmd_universe.c common/cmd_universe.c: Fix GCC 4.6 build warning 2011-11-16 21:04:55 +01:00
cmd_unzip.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_usb_mass_storage.c usb:gadget: USB Mass Storage Gadget support 2013-03-18 18:58:53 +01:00
cmd_usb.c usb: use linux/usb/ch9.h instead of usbdescriptors.h 2012-11-20 00:16:06 +01:00
cmd_version.c x86: Add coreboot version to u-boot's version command 2012-12-26 10:36:26 -08:00
cmd_ximg.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_yaffs2.c u-boot: Update yaffs2 file system 2012-08-09 23:39:18 +02:00
cmd_zfs.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
cmd_zip.c common: Use new numeric setenv functions 2013-02-28 19:09:23 -08:00
command.c cmd_time: merge run_command_and_time_it with cmd_process 2013-02-04 09:14:02 -05:00
console.c env: Add a silent env handler 2012-12-13 11:46:56 -07:00
ddr_spd.c mpc8xxx: DDR2/DDR3: Clean up DIMM-type switch statements 2011-04-04 09:24:43 -05:00
dlmalloc.c Consolidate bool type 2013-04-01 16:33:52 -04:00
dlmalloc.src Consolidate bool type 2013-04-01 16:33:52 -04:00
edid.c edid: Library of EDID decode and print 2012-12-11 13:17:34 -07:00
env_attr.c tools/env: Add environment variable flags support 2012-12-13 11:46:56 -07:00
env_callback.c env_callback: Mark find_env_callback as static 2013-03-27 15:30:11 -04:00
env_common.c env: Add support for access control to .flags 2012-12-13 11:46:56 -07:00
env_dataflash.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_eeprom.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_embedded.c env: cosmetic: Consilidate the default env definition 2012-10-19 15:25:43 -07:00
env_fat.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_flags.c env: Handle write-once ethaddr and serial# generically 2012-12-13 11:46:57 -07:00
env_flash.c env: Hide '.' variables in env print by default 2012-12-13 11:46:55 -07:00
env_mmc.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_nand.c nand: Extend nand_(read|write)_skip_bad with *actual and limit parameters 2013-04-10 15:22:22 +02:00
env_nowhere.c env: factor out the env_get_char_spec() function 2012-01-05 16:34:10 +01:00
env_nvram.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_onenand.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_remote.c env: remove duplicated env_get_char_spec() 2012-09-26 11:08:32 -07:00
env_sf.c Revert "env: fix potential stack overflow in environment functions" 2013-04-05 14:55:21 -04:00
env_ubi.c env: Add redundant env support to UBI env 2013-04-11 15:52:55 -04:00
exports.c Fix SPI build errors in exports.c 2011-12-07 08:41:22 +01:00
fdt_support.c common/fdt_support.c: sparse fixes 2013-02-07 20:38:55 -05:00
flash.c flash: Add optional verify-after-write feature 2013-04-22 10:56:38 +02:00
hash.c gen: Add sha h/w acceleration to hash 2013-03-29 20:10:42 +09:00
hush.c cmd_time: merge run_command_and_time_it with cmd_process 2013-02-04 09:14:02 -05:00
hwconfig.c Minor Coding Style Cleanup. 2011-02-02 22:36:10 +01:00
image.c image: Add support for Plan 9 2013-03-27 15:30:11 -04:00
iomux.c serial: remove calls to serial_assign() 2012-10-29 09:07:06 -07:00
kallsyms.c Add support for Linux-like kallsysms 2009-06-12 20:45:48 +02:00
kgdb_stubs.c kgdb: add default generic stubs 2010-01-18 00:23:00 +01:00
kgdb.c Make sure that argv[] argument pointers are not modified. 2010-07-04 23:55:42 +02:00
lcd.c video: bcm2835: fix build issues 2013-03-29 14:29:39 +01:00
lynxkdi.c checkpatch whitespace cleanups 2011-10-22 01:13:35 +02:00
main.c Revert "fdt- Tell the FDT library where the device tree is" 2013-05-01 11:17:21 -04:00
Makefile env: Add support for UBI environment 2013-04-11 15:52:55 -04:00
memsize.c Revert "memsize: Fix for bug in memory sizing code" 2012-09-21 08:14:05 -07:00
menu.c menu: export menu_default_choice() function 2013-03-29 09:35:34 +01:00
miiphyutil.c Revert "mii: miiphy register address width change" 2011-12-07 08:35:14 +01:00
modem.c common: move extern char console_buffer[] to common.h 2011-11-22 08:39:25 +01:00
s_record.c Initial revision 2002-08-17 09:36:01 +00:00
stdio.c serial: arm_dcc: Remove CONFIG_ARM_DCC_MULTI option 2013-02-04 09:14:21 -05:00
system_map.c Add support for Linux-like kallsysms 2009-06-12 20:45:48 +02:00
update.c net/: sparse fixes 2012-11-04 11:00:36 -07:00
usb_hub.c usb: Clean up newly allocated device nodes in case of configuration failure 2012-12-17 15:38:15 +01:00
usb_kbd.c USB: add arrow key support to usb_kbd 2012-11-20 00:16:06 +01:00
usb_storage.c usb: properly detect empty mass storage media reader 2012-12-17 15:38:15 +01:00
usb.c usb: Clean up newly allocated device nodes in case of configuration failure 2012-12-17 15:38:15 +01:00
xyzModem.c common/misc: sparse fixes 2012-11-04 11:00:35 -07:00