Closed carlos-montiers closed 4 years ago
Colon is already used by CMD.
I tested this:
set "$var=[ oKay ]"
echo !$var;trim[ oy]!
echo !$var;trim: oy]!
echo !$var;trim: oy!
It outputs:
Kay ]
$var;trim: oy]
$var;trim: oy
Thus for some reason inly works with square brackets and that is what I want remove for use a single colon as begin of the argument.
Colon is used by CMD, so EB sees $var;trim
as the variable. Disable CMD extensions if you want to use colon.
Colon is used by CMD, so EB sees
$var;trim
as the variable. Disable CMD extensions if you want to use colon.
Mmm thus the colon should be a prohibited character for use in the filters, it will confuse the sentence? Maybe we can do some trick inthe lex stage?
No, it doesn't go through lex, it would require a patch. Just disable extensions.
What you're actually asking is how to add [
and ]
to the list: it's not nested, so after the opening bracket [
is just a character; the list can't be empty, so ]
immediately after the opening [
is just a character. Thus to trim []
use trim[][]
- open [
, character ]
, character [
, close ]
. Sorry I didn't make that clear.
No, it doesn't go through lex, it would require a patch. Just disable extensions.
Maybe we can automatically disable extensions and reenable when the : character appears in the filter, currently I cannot filter the colon:
set "$var= oKay: " echo !$var;trim[:a]!
Or maybe add a mechanism for allow trim the colon character, for example: colontrim (trim including colon) ?
In order to know if colon is in the list we would have to parse the line before CMD sees it (which we could do, but it's a waste of time). Delayed expansion doesn't work, either, as it's already expanded at this point. Could provide a substitute (e.g. if we see U+FF3A replace it with U+003A) or escape it (some sort of equivalent to \x3a
), but it doesn't seem worth it. Just disable extensions.
set @extensions=0
echo !$var;trim[:a]!
set @extensions=1
I add this note about this workaround for the colon character in the documentation
I propose change the syntax for the filter arguments from use two square brackets to a single colon.
For example from this:
trim[ oy]
totrim: oy
That will simplify the usage.