<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def maybe_shorten_name(powerline, name):
 """If the user has asked for each directory name to be shortened, will return the name up to their specified length. Otherwise returns the full name."""

    max_size = powerline.segment_conf("cwd", "max_dir_size")
    if max_size:
        return name[:max_size]
    return name