code: def test_run_cmdline_disambiguation(path=None):
      Dataset(path).create()
      with chpwd(path):
          # Without a positional argument starting a command, any option is
          # treated as an option to 'datalad run'.
          with swallow_outputs() as cmo:
              with patch(
                  "datalad.core.local.run._execute_command"
              ) as exec_cmd:
                  with assert_raises(SystemExit):
                      main(["datalad", "run", "--message"])
                  exec_cmd.assert_not_called()
              assert_in("message: expected one", cmo.err)
          # If we want to pass an option as the first value of a command (e.g.,
          # because we are using a runscript with containers-run), we can do this
          # with "--".
          with patch(
              "datalad.core.local.run._execute_command"
          ) as exec_cmd:
              with assert_raises(SystemExit):
                  main(["datalad", "run", "--", "--message"])
              exec_cmd.assert_called_once_with(
                  '"--message"' if on_windows else "--message", path
              )
  
          # Our parser used to mishandle --version (gh-3067),
          # treating 'datalad run CMD --version' as 'datalad --version'.
          # but that is no longer the case and echo --version should work with or
          # without explicit "--" separator
          for sep in [[], ["--"]]:
              with patch(
                  "datalad.core.local.run._execute_command"
              ) as exec_cmd:
                  with assert_raises(SystemExit):
                      main(
                          ["datalad", "run"]
                          + sep
                          + ["echo", "--version"]
                      )
                  exec_cmd.assert_called_once_with(
                      '"echo" "--version"'
                      if on_windows
                      else "echo --version",
                      path,
                  )
  
imports: import logging
  import os
  import os.path
  import sys
  from os import mkdir, remove
  from unittest.mock import patch
  from datalad.api import clone, run
  from datalad.cli.main import main
  from datalad.core.local.run import _format_iospecs, _get_substitutions, format_command, run_command
  from datalad.distribution.dataset import Dataset
  from datalad.support.exceptions import CommandError, IncompleteResultsError, NoDatasetFound
  from datalad.tests.utils_pytest import DEFAULT_BRANCH, OBSCURE_FILENAME, assert_false, assert_in, assert_in_results, assert_not_in, assert_not_in_results, assert_raises, assert_repo_status, assert_result_count, assert_status, create_tree, eq_, known_failure_windows, neq_, ok_, ok_exists, ok_file_has_content, patch_config, swallow_logs, swallow_outputs, with_tempfile, with_tree
  from datalad.utils import chpwd, ensure_unicode, on_windows
label_desc: Use image node_id 14 for calling a global function with example usage: test_run_cmdline_disambiguation(path) without return types