followup of #18632

in addition to the described bug in #18632, shlex.split is used to split enviroment and args, and both will fail if the default `None` is given to .split because as python manual states:

`Since the split() function instantiates a shlex instance, passing None for s will read the string to split from standard input.` 

which leads to shlex.split waiting for input from stdin forever.

This change takes care of `None`.
In addition it  reuses the environment parsing code from cmdmod.py to deal with environment variables without a value