From b611aa4943b98d4d882c7960b512907adaf7bf73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Andr=C3=A9e?= Date: Sat, 4 Apr 2015 12:53:11 +0200 Subject: [PATCH] fix for zsh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- completion/auto-auto-complete.py | 100 +++++++++++++++++++++++++++++-- completion/ponysay | 2 +- 2 files changed, 97 insertions(+), 5 deletions(-) diff --git a/completion/auto-auto-complete.py b/completion/auto-auto-complete.py index bdeb9e47..398305a9 100755 --- a/completion/auto-auto-complete.py +++ b/completion/auto-auto-complete.py @@ -274,7 +274,7 @@ class GeneratorBASH: return '\'' + text.replace('\'', '\'\\\'\'') + '\'' def makeexec(functionType, function): - if functionType in ('exec', 'pipe', 'fullpipe', 'cat', 'and', 'or'): + if functionType in ('exec', 'pipe', 'fullpipe', 'cat', 'and', 'or', 'stdin', 'stdout', 'stderr', 'stdin-fd', 'stdout-fd', 'stderr-fd', 'fd', 'fd-fd'): elems = [(' %s ' % makeexec(item[0], item[1:]) if isinstance(item, list) else verb(item)) for item in function] if functionType == 'exec': return ' $( %s ) ' % (' '.join(elems)) @@ -288,6 +288,36 @@ class GeneratorBASH: return ' ( %s ) ' % (' && '.join(elems)) if functionType == 'or': return ' ( %s ) ' % (' || '.join(elems)) + if functionType == 'stdin': + if len(elems) == 0: + return 0 + [command, redirection] = elems + return ' %s < %s ' % (command, redirection) + if functionType == 'stdout': + if len(elems) == 0: + return 1 + [command, redirection] = elems + return ' %s > %s ' % (command, redirection) + if functionType == 'stderr': + if len(elems) == 0: + return 2 + [command, redirection] = elems + return ' %s 2> %s ' % (command, redirection) + if functionType == 'stdin-fd': + [command, redirection] = elems + return ' %s <&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'stdout-fd': + [command, redirection] = elems + return ' %s >&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'stderr-fd': + [command, redirection] = elems + return ' %s 2>&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'fd': + [command, fd, redirection] = elems + return ' %s %s<> %s ' % (command, fd.replace('\'', '').replace(' ', ''), redirection) + if functionType == 'fd-fd': + [command, fd, redirection] = elems + return ' %s %s<>&%s ' % (command, fd.replace('\'', '').replace(' ', ''), redirection.replace('\'', '').replace(' ', '')) if functionType in ('params', 'verbatim'): return ' '.join([verb(item) for item in function]) return ' '.join([verb(functionType)] + [verb(item) for item in function]) @@ -470,7 +500,7 @@ class GeneratorFISH: return '\'' + text.replace('\'', '\'\\\'\'') + '\'' def makeexec(functionType, function): - if functionType in ('exec', 'pipe', 'fullpipe', 'cat', 'and', 'or'): + if functionType in ('exec', 'pipe', 'fullpipe', 'cat', 'and', 'or', 'stdin', 'stdout', 'stderr', 'stdin-fd', 'stdout-fd', 'stderr-fd', 'fd', 'fd-fd'): elems = [(' %s ' % makeexec(item[0], item[1:]) if isinstance(item, list) else verb(item)) for item in function] if functionType == 'exec': return ' ( %s ) ' % (' '.join(elems)) @@ -484,6 +514,36 @@ class GeneratorFISH: return ' ( %s ) ' % (' && '.join(elems)) if functionType == 'or': return ' ( %s ) ' % (' || '.join(elems)) + if functionType == 'stdin': + if len(elems) == 0: + return 0 + [command, redirection] = elems + return ' %s < %s ' % (command, redirection) + if functionType == 'stdout': + if len(elems) == 0: + return 1 + [command, redirection] = elems + return ' %s > %s ' % (command, redirection) + if functionType == 'stderr': + if len(elems) == 0: + return 2 + [command, redirection] = elems + return ' %s 2> %s ' % (command, redirection) + if functionType == 'stdin-fd': + [command, redirection] = elems + return ' %s <&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'stdout-fd': + [command, redirection] = elems + return ' %s >&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'stderr-fd': + [command, redirection] = elems + return ' %s 2>&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'fd': + [command, fd, redirection] = elems + return ' %s %s<> %s ' % (command, fd.replace('\'', '').replace(' ', ''), redirection) + if functionType == 'fd-fd': + [command, fd, redirection] = elems + return ' %s %s<>&%s ' % (command, fd.replace('\'', '').replace(' ', ''), redirection.replace('\'', '').replace(' ', '')) if functionType in ('params', 'verbatim'): return ' '.join([verb(item) for item in function]) return ' '.join([verb(functionType)] + [verb(item) for item in function]) @@ -664,7 +724,7 @@ class GeneratorZSH: return '\'' + text.replace('\'', '\'\\\'\'') + '\'' def makeexec(functionType, function): - if functionType in ('exec', 'pipe', 'fullpipe', 'cat', 'and', 'or'): + if functionType in ('exec', 'pipe', 'fullpipe', 'cat', 'and', 'or', 'stdin', 'stdout', 'stderr', 'stdin-fd', 'stdout-fd', 'stderr-fd', 'fd', 'fd-fd'): elems = [(' %s ' % makeexec(item[0], item[1:]) if isinstance(item, list) else verb(item)) for item in function] if functionType == 'exec': return ' $( %s ) ' % (' '.join(elems)) @@ -678,6 +738,36 @@ class GeneratorZSH: return ' ( %s ) ' % (' && '.join(elems)) if functionType == 'or': return ' ( %s ) ' % (' || '.join(elems)) + if functionType == 'stdin': + if len(elems) == 0: + return 0 + [command, redirection] = elems + return ' %s < %s ' % (command, redirection) + if functionType == 'stdout': + if len(elems) == 0: + return 1 + [command, redirection] = elems + return ' %s > %s ' % (command, redirection) + if functionType == 'stderr': + if len(elems) == 0: + return 2 + [command, redirection] = elems + return ' %s 2> %s ' % (command, redirection) + if functionType == 'stdin-fd': + [command, redirection] = elems + return ' %s <&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'stdout-fd': + [command, redirection] = elems + return ' %s >&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'stderr-fd': + [command, redirection] = elems + return ' %s 2>&%s ' % (command, redirection.replace('\'', '').replace(' ', '')) + if functionType == 'fd': + [command, fd, redirection] = elems + return ' %s %s<> %s ' % (command, fd.replace('\'', '').replace(' ', ''), redirection) + if functionType == 'fd-fd': + [command, fd, redirection] = elems + return ' %s %s<>&%s ' % (command, fd.replace('\'', '').replace(' ', ''), redirection.replace('\'', '').replace(' ', '')) if functionType in ('params', 'verbatim'): return ' '.join([verb(item) for item in function]) return ' '.join([verb(functionType)] + [verb(item) for item in function]) @@ -726,7 +816,9 @@ class GeneratorZSH: continue buf += ' \'(%s)\'{%s}' % (' '.join(options), ','.join(options)) if 'desc' in item: - buf += '"["%s"]"' % verb(' '.join(item['desc'])) + desc = ' '.join(item['desc']) + desc = desc.replace('\\', '\\\\').replace('[', '\\[').replace(']', '\\]') + buf += '"["%s"]"' % verb(desc) if 'arg' in item: buf += '":%s"' % verb(' '.join(item['arg'])) elif options[0] in suggesters: diff --git a/completion/ponysay b/completion/ponysay index 8754a981..fc10665d 100644 --- a/completion/ponysay +++ b/completion/ponysay @@ -62,7 +62,7 @@ (no-exec ls "'/usr/share/ponysay/balloons'" (case (ponysay .say) (ponythink .think))) ) (suggestion wrap (verbatim none inherit 100 60) - (calc (pipe (stty size) + (calc (pipe (stdin-fd (stty size) (stderr)) (cut -d ' ' -f 2) ) - 10 )