<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def which(program, path=None):
 """ Returns the full path of shell commands. Replicates the functionality of system which (1) command. Looks for the named program in the directories indicated in the $PATH environment variable, and returns the full path if found. Examples: "/bin/ls" "/bin/ls" None "/bin/ls" Arguments: program (str):
 The name of the program to look for. Can be an absolute path. path (sequence of str, optional):
 A list of directories to look for the pgoram in. Default value is system $PATH. Returns: str: Full path to program if found, else None. """

    # If path is not given, read the $PATH environment variable.
    path = path or os.environ["PATH"].split(os.pathsep)
    abspath = True if os.path.split(program)[0] else False
    if abspath:
        if fs.isexe(program):
            return program
    else:
        for directory in path:
            # De-quote directories.
            directory = directory.strip('"')
            exe_file = os.path.join(directory, program)
            if fs.isexe(exe_file):
                return exe_file

    return None