If the word under the cursor started with a quote (as indicated by a nonempty ``cword_prequote``), escapes
        occurrences of that quote character in the completions, and adds the quote to the beginning of each completion.
        Otherwise, escapes all characters that bash splits words on (``COMP_WORDBREAKS``), and removes portions of
        completions before the first colon.

        If there is only one completion, and it doesn't end with a **continuation character** (``/``, ``:``, or ``=``),
        adds a space after the completion.

        This method is exposed for overriding in subclasses; there is no need to use it directly.

def quote_completions(self, completions, cword_prequote, first_colon_pos):
        '''
        If the word under the cursor started with a quote (as indicated by a nonempty ``cword_prequote``), escapes
        occurrences of that quote character in the completions, and adds the quote to the beginning of each completion.
        Otherwise, escapes all characters that bash splits words on (``COMP_WORDBREAKS``), and removes portions of
        completions before the first colon.

        If there is only one completion, and it doesn't end with a **continuation character** (``/``, ``:``, or ``=``),
        adds a space after the completion.

        This method is exposed for overriding in subclasses; there is no need to use it directly.
        '''
        comp_wordbreaks = os.environ.get('_ARGCOMPLETE_COMP_WORDBREAKS', os.environ.get('COMP_WORDBREAKS', self.wordbreaks))
        if USING_PYTHON2:
            comp_wordbreaks = comp_wordbreaks.decode(sys_encoding)

        punctuation_chars = '();<>|&!`'
        for char in punctuation_chars:
            if char not in comp_wordbreaks:
                comp_wordbreaks += char

        # If the word under the cursor was quoted, escape the quote char and add the leading quote back in.
        # Otherwise, escape all COMP_WORDBREAKS chars.
        if cword_prequote == '':
            # Bash mangles completions which contain colons.
            # This workaround has the same effect as __ltrim_colon_completions in bash_completion.
            if first_colon_pos:
                completions = [c[first_colon_pos+1:] for c in completions]

            for wordbreak_char in comp_wordbreaks:
                completions = [c.replace(wordbreak_char, '\\'+wordbreak_char) for c in completions]
        else:
            if cword_prequote == '"':
                for char in '`$!':
                    completions = [c.replace(char, '\\'+char) for c in completions]
            completions = [cword_prequote+c.replace(cword_prequote, '\\'+cword_prequote) for c in completions]

        # Note: similar functionality in bash is turned off by supplying the "-o nospace" option to complete.
        # We can't use that functionality because bash is not smart enough to recognize continuation characters (/) for
        # which no space should be added.
        continuation_chars = '=/:'
        if len(completions) == 1 and completions[0][-1] not in continuation_chars:
            if cword_prequote == '' and not completions[0].endswith(' '):
                completions[0] += ' '

        return completions