code: def shell_complete(
      cli: BaseCommand,
      ctx_args: t.MutableMapping[str, t.Any],
      prog_name: str,
      complete_var: str,
      instruction: str,
  ) -> int:
      """Perform shell completion for the given CLI program.
  
      :param cli: Command being called.
      :param ctx_args: Extra arguments to pass to
          ``cli.make_context``.
      :param prog_name: Name of the executable in the shell.
      :param complete_var: Name of the environment variable that holds
          the completion instruction.
      :param instruction: Value of ``complete_var`` with the completion
          instruction and shell, in the form ``instruction_shell``.
      :return: Status code to exit with.
      """
      shell, _, instruction = instruction.partition("_")
      comp_cls = get_completion_class(shell)
  
      if comp_cls is None:
          return 1
  
      comp = comp_cls(cli, ctx_args, prog_name, complete_var)
  
      if instruction == "source":
          echo(comp.source())
          return 0
  
      if instruction == "complete":
          echo(comp.complete())
          return 0
  
      return 1
  
imports: import os
  import re
  import typing
  from gettext import gettext
  from .core import Argument
  from .core import BaseCommand
  from .core import Context
  from .core import MultiCommand
  from .core import Option
  from .core import Parameter
  from .core import ParameterSource
  from .parser import split_arg_string
  from .utils import echo
label_desc: Use image node_id 1 for calling a global function with example usage: shell_complete(cli, ctx_args, prog_name, complete_var, instruction) and returns: int, int, int, int