Fix substring operation in 'magic' variable expansion.
In substring expansion of variables, the length computation wasn't the same between:
- magic variables: length doesn't include terminating NUL
- regular variables: length does include terminating NUL This led to incorrect substring operation for magic variables. Always set length to not include terminating NUL. Took the opportunity to not recompute length (as it's already computed by called functions).