Luca Saiu wrote:
> > Are you sure you don't want to use glob() or fnmatch() instead?
> 
> What I actually need is variable expansion, and wordexp can be called to
> do (almost) only that;

wordexp [1] also has a notion of quoting and unquoting. And of invalid 
characters
(<newline>, '|', '&', ';', '<', '>', '(', ')', '{', '}').

> In the end I am implementing something from scratch.

Then I would suggest just a homemade function that parses a string and does
variable expansion. This way you control the syntax and also what happens if
a variable's expansion references another variable. It's about 50 to 100 lines
of code to write it from scratch.

But if you really want wordexp(), then you can borrow the code from glibc
(2500 lines of code) and propose it as a Gnulib module [2], then use it from
Gnulib.

Bruno

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/wordexp.html
[2] https://www.gnu.org/software/gnulib/manual/html_node/Writing-modules.html




Reply via email to