Ejemplo n.º 1
0
 def test_custom_helpopt2_nullglob(self, bash):
     assert_bash_exec(bash, "fn() { [[ $1 == '-?' ]] && echo '-option'; }")
     with bash_env_saved(bash) as bash_env:
         bash_env.shopt("nullglob", True)
         output = assert_bash_exec(bash,
                                   "_parse_help fn '-?'",
                                   want_output=True)
     assert output.split() == "-option".split()
 def test_custom_helpopt2_failglob(self, bash):
     assert_bash_exec(bash,
                      "fn() { [[ $1 == '-?' ]] && echo 'fn [-option]'; }")
     with bash_env_saved(bash) as bash_env:
         bash_env.shopt("failglob", True)
         output = assert_bash_exec(bash,
                                   "_parse_usage fn '-?'",
                                   want_output=True)
     assert output.split() == "-o -p -t -i -o -n".split()
Ejemplo n.º 3
0
    def test_10(self, request, bash, colonpath):
        with bash_env_saved(bash) as bash_env:
            bash_env.write_env(
                "MANPATH",
                "%s:%s/man" % (TestMan.manpath, colonpath),
                quote=False,
            )

            completion = assert_complete(bash, "man Bash::C")
            assert completion == "ompletion"
Ejemplo n.º 4
0
 def test_something(self, bash):
     """Test that we get something."""
     with bash_env_saved(bash) as bash_env:
         bash_env.write_variable("cur", "")
         completion = assert_bash_exec(
             bash,
             r'_pids; printf "%s\n" "${COMPREPLY[@]}"',
             want_output=True,
         ).split()
     assert completion
Ejemplo n.º 5
0
 def test_user_home_compreply_failglob(self, bash, user_home):
     user, home = user_home
     with bash_env_saved(bash) as bash_env:
         bash_env.shopt("failglob", True)
         output = assert_bash_exec(
             bash,
             r'cur="~%s"; _expand; printf "%%s\n" "$COMPREPLY"' % user,
             want_output=True,
         )
     assert output.strip() == home
Ejemplo n.º 6
0
 def test_ints(self, bash):
     """Test that we get something, and only ints."""
     with bash_env_saved(bash) as bash_env:
         bash_env.write_variable("cur", "")
         completion = assert_bash_exec(
             bash,
             r'_pids; printf "%s\n" "${COMPREPLY[@]}"',
             want_output=True,
         ).split()
     assert completion
     assert all(x.isdigit() for x in completion)
 def test_no_globbing(self, bash):
     with bash_env_saved(bash) as bash_env:
         bash_env.write_variable("HOME", "%s/_known_hosts_real" % bash.cwd)
         bash_env.chdir("_known_hosts_real")
         output = assert_bash_exec(
             bash,
             "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
             "_known_hosts_real -aF config ''; "
             r'printf "%s\n" "${COMPREPLY[@]}"',
             want_output=True,
         )
     completion = sorted(set(output.strip().split()))
     assert "gee" in completion
     assert "gee-filename-canary" not in completion
Ejemplo n.º 8
0
    def test_github_issue_492_4(self, bash):
        """Test error messages through unintended pathname expansions

        When "shopt -s failglob" is set by the user, the completion of the word
        containing glob character and special characters (e.g. TAB) results in
        the failure of pathname expansions.

          $ shopt -s failglob
          $ echo a\\	b*[TAB]

        """
        with bash_env_saved(bash) as bash_env:
            bash_env.shopt("failglob", True)
            assert_bash_exec(bash, "quote_readline $'a\\\\\\tb*' >/dev/null")
Ejemplo n.º 9
0
    def test_files_starting_with_tilde(self, bash, hosts):
        expected = hosts.copy()
        # fixtures/_known_hosts_real/known_hosts2
        expected.extend("two two2 two3 two4".split())
        # fixtures/_known_hosts_real/known_hosts3
        expected.append("three")
        # fixtures/_known_hosts_real/known_hosts4
        expected.append("four")

        with bash_env_saved(bash) as bash_env:
            bash_env.write_variable("HOME", bash.cwd)
            output = assert_bash_exec(
                bash,
                "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
                "_known_hosts_real -aF _known_hosts_real/config_tilde ''; "
                r'printf "%s\n" "${COMPREPLY[@]}"',
                want_output=True,
            )

        assert sorted(set(output.strip().split())) == sorted(expected)
    def test_included_configs(self, bash, hosts):
        expected = hosts.copy()
        # fixtures/_known_hosts_real/config_include_recursion
        expected.append("recursion")
        # fixtures/_known_hosts_real/.ssh/config_relative_path
        expected.append("relative_path")
        # fixtures/_known_hosts_real/.ssh/config_asterisk_*
        expected.extend("asterisk_1 asterisk_2".split())
        # fixtures/_known_hosts_real/.ssh/config_question_mark
        expected.append("question_mark")

        with bash_env_saved(bash) as bash_env:
            bash_env.write_variable("HOME", "%s/_known_hosts_real" % bash.cwd)
            output = assert_bash_exec(
                bash,
                "unset -v COMPREPLY COMP_KNOWN_HOSTS_WITH_HOSTFILE; "
                "_known_hosts_real -aF _known_hosts_real/config_include ''; "
                r'printf "%s\n" "${COMPREPLY[@]}"',
                want_output=True,
            )
        assert sorted(set(output.strip().split())) == sorted(expected)
Ejemplo n.º 11
0
 def test_smoke(self, bash):
     with bash_env_saved(bash) as bash_env:
         bash_env.write_variable("cur", "")
         assert_bash_exec(bash, "_pids >/dev/null")
Ejemplo n.º 12
0
 def test_17_failglob(self, bash):
     assert_bash_exec(bash, "fn() { echo '--foo[=bar]'; }")
     with bash_env_saved(bash) as bash_env:
         bash_env.shopt("failglob", True)
         output = assert_bash_exec(bash, "_parse_help fn", want_output=True)
     assert output.split() == "--foo".split()