code: def _ls_remote_path(ssh, path):
      try:
          # yoh tried ls on mac
          # escape path explicitly with shlex.quote as 'sh' is a POSIX shell and
          # sh_quote could decide to quote Windows-style
          # C.UTF-8 locale as opposed to C locale handles special characters (umlauts etc.)
          # ls falls back to C locale if LC_ALL is set to unknown locale, so this should be safe.
          ls_cmd = (
              "LC_ALL=C.UTF-8; export LC_ALL; /bin/ls -A1 {}".format(
                  shlex.quote(path)
              )
          )
          # TODO: Using sh_quote here is also flawed as it checks whether the
          # *local* machine is Windows. Doesn't help if the remote we're ssh'ing in is Windows.
          ssh_cmd = "sh -c {}".format(sh_quote(ls_cmd))
          out, err = ssh(ssh_cmd)
  
          if err:
              # we might even want to raise an exception, but since it was
              # not raised, let's just log a warning
              lgr.warning(
                  "There was some output to stderr while running ls on %s via ssh: %s",
                  path,
                  err,
              )
      except CommandError as e:
          if (
              "No such file or directory" in e.stderr
              and path in e.stderr
          ):
              return None
          else:
              raise  # It's an unexpected failure here
      return [l for l in out.split(os.linesep) if l]
  
imports: import logging
  import os
  from os.path import curdir
  import shlex
  from os.path import join
  from os.path import normpath, relpath
  from looseversion import LooseVersion
  from datalad import ssh_manager
  from datalad.cmd import CommandError, StdOutErrCapture, WitlessRunner
  from datalad.consts import TIMESTAMP_FMT, WEB_META_LOG
  from datalad.core.local.diff import diff_dataset
  from datalad.distribution.dataset import Dataset, EnsureDataset, datasetmethod, require_dataset, resolve_path
  from datalad.distribution.siblings import Siblings, _DelayedSuper
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_opts import annex_group_opt, annex_groupwanted_opt, annex_wanted_opt, as_common_datasrc, inherit_opt, publish_by_default, publish_depends, recursion_flag, recursion_limit
  from datalad.support.annexrepo import AnnexRepo
  from datalad.support.constraints import EnsureBool, EnsureChoice, EnsureNone, EnsureStr
  from datalad.support.exceptions import CapturedException, InsufficientArgumentsError, MissingExternalDependency
  from datalad.support.external_versions import external_versions
  from datalad.support.network import RI, PathRI, is_ssh
  from datalad.support.param import Parameter
  from datalad.ui import ui
  from datalad.utils import _path_, ensure_list, make_tempfile, on_windows
  from datalad.utils import quote_cmdlinearg
  from datalad.utils import slash_join
label_desc: Use image node_id 2 for calling a global function with example usage: _ls_remote_path(ssh, path) and returns: unknown, None