cmd: Fix out-of-bound access when handling tilde modifiers. wcschr(str, 0) returns the end of the string, not NULL.