Don't repeat length computation

The length of the current string has to be computed when mxsh parses the
built-in command line. This is done repeatedly when needed. This is
prone to errors. Do the computation once and use it where applicable.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>