[Close window]

Expandstrings

or how to get advantage of brace expansion in Windows

Brace expansion is a feature of GNU Bash that permits to express a set of similar strings with a compact notation, according to some grammar rule like this:

Note: you can see that grammar definition is recursive, so that brace nesting is allowed; you can write for example "a{b,c{D,E}}XXX".

expandstrings is a simple Win32 utility that performs brace expansion of an input string; result is a set of all generated strings, one per line. Optionally, expandstrings will draw the syntax tree of your expression, to let you better understand and debug your experiments.

Command line arguments

------------------------------------------------------------------
Usage: expandstrings [-d] [-t] [-p] [-r] [-h|--help] [-e ]
	-d	debug mode
	-t	print tree structure
	-p	print output
	-r	print return code (0=ok, nonzero=error)
	-h | --help  this help screen
	-e string    pass string on command line

Note that -e must be the last option on command line.
If no -e option is present, input is read from standard input.
------------------------------------------------------------------

Special symbols

"{", "}" and "," chars can't be used for text as they are needed to build the structured expression. You can insert them as text if they are preceded by "\" symbol; use "\\" symbol to add a single "\" in text. Finally, use "\*" to insert a null string in a string list value.

Simple examples

Developing and compilation details

This utility was built on Windows XP, using the MSYS+MinGW+UnxUtils packages to obtain a Unix-like environment. Executable is for Win32 platforms, but sources and makefile should compile straight under standard Unix/Linux systems (any feedback will be appreciated, thanks in advance).

Sources weren't commented, so some effort is needed to understand them. Spreading modified versions is of course freely allowed, but then please cite this website (http://andrear.altervista.org) as the original version repository. Have fun experimenting.

Download