<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def build_sh_cmd(cmd, cwd=None):
 """Build a `sh.Command` from a string. :param cmd: String with the command to convert. :param cwd: Optional path to use as working directory. :return: `sh.Command` """

    args = cmd.split()
    return getattr(sh, args[0]).bake(_cwd=cwd, *args[1:])