def set_variable(section, value, create):
    """
    Set value of a variable in an environment file for the given section.
    If the variable is already defined, its value is replaced, otherwise, it is added to the end of the file.
    The value is given as "ENV_VAR_NAME=env_var_value", e.g.:

    s3conf set test ENV_VAR_NAME=env_var_value
    """
    if not value:
        value = section
        section = None
    try:
        logger.debug('Running env command')
        settings = config.Settings(section=section)
        conf = s3conf.S3Conf(settings=settings)

        env_vars = conf.get_envfile()
        env_vars.set(value, create=create)
    except exceptions.EnvfilePathNotDefinedError:
        raise exceptions.EnvfilePathNotDefinedUsageError()