I don't see how this is expected to (reliably) work.  First of all, it's going to fail horribly if the options to the actually command include an '=' as in:
```
/bin/env KEY=VALUE NAME=CONTENT command --option=enabled
```
You're going to fall of the end and be upset !
You set last_pos to pos + 1, to step over the space (or '=') that you're on; this is borked if there are several spaces together.  You need to `for (last_pos = pos + 1; isspace(*last_pos); last_pos++) { /* skip */ }` for that, but only when `*pos` was a space.
We start with pos just before KEY: so strpbrk(last_pos, "= ") is useful; but we need to keep track of whether last time round the loop we were looking at a space or an =; if we were looking at ' ' (have stepped over all further space) and strpbrk() finds us another before we hit an '=', then CommandArg0(last_pos) is what we want.  (Yay!)
If we were looking at an =, we need to strpbrk(last_pos, ' ') ignoring any intervening '=' (as the value of a variable can have '=' in it).
So try:
```
while (true)
{
    const char *last_pos = pos + 1;
    assert(isspace(*pos));
    while (isspace(*last_pos)) { last_pos++; }
    pos = strpbrk(last_pos, "\t =");
    if (isspace(*pos)) { return CommandArg0(last_pos); }
    pos = strpbrk(pos, "\t ");
}
```