code: def do_shell(self, args: argparse.Namespace) -> None:
          
          import subprocess
  
          # Create a list of arguments to shell
          tokens = [args.command] + args.command_args
  
          # Support expanding ~ in quoted paths
          for index, _ in enumerate(tokens):
              if tokens[index]:
                  # Check if the token is quoted. Since parsing already passed, there isn't
                  # an unclosed quote. So we only need to check the first character.
                  first_char = tokens[index][0]
                  if first_char in constants.QUOTES:
                      tokens[index] = utils.strip_quotes(tokens[index])
  
                  tokens[index] = os.path.expanduser(tokens[index])
  
                  # Restore the quotes
                  if first_char in constants.QUOTES:
                      tokens[index] = first_char + tokens[index] + first_char
  
          expanded_command = ' '.join(tokens)
  
          # Prevent KeyboardInterrupts while in the shell process. The shell process will
          # still receive the SIGINT since it is in the same process group as us.
          with self.sigint_protection:
              # For any stream that is a StdSim, we will use a pipe so we can capture its output
              proc = subprocess.Popen(expanded_command,
                                      stdout=subprocess.PIPE if isinstance(self.stdout, utils.StdSim) else self.stdout,
                                      stderr=subprocess.PIPE if isinstance(sys.stderr, utils.StdSim) else sys.stderr,
                                      shell=True)
  
              proc_reader = utils.ProcReader(proc, self.stdout, sys.stderr)
              proc_reader.wait()
docs: Execute a command as if at the OS prompt