c - Wordexp behavour with & -
does knows wordexp()
behaviour strings, contained '|'
or '&'
.
i use wordexp(str, &res, wrde_undef)
, strings, contained '|'
or '&'
wordexp()
returns wrde_badchar
. want wordexp()
doesn't report this.
e.g. want wordexp("a & b", &res, wrde_undef)
returns wordexp_t
3 strings "a" "&" "b"
.
illegal characters (newline
or |
, &
, ;
, <
, >
, (
, )
, {
, }
) need escaped. done prefixing them \
.
verbatim man wordexp
:
the string argument
since expansion same expansion shell (see sh(1)) of parameters command, string s must not contain characters illegal in shell command parameters. in particular, there must not unescaped newline or |, &, ;, <, >, (, ), {, } characters outside command substitution or parameter substitution context.
Comments
Post a Comment