aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/auto-auto-complete.py96
1 files changed, 93 insertions, 3 deletions
diff --git a/src/auto-auto-complete.py b/src/auto-auto-complete.py
index da8d56f..f883b36 100755
--- a/src/auto-auto-complete.py
+++ b/src/auto-auto-complete.py
@@ -266,7 +266,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))
@@ -280,6 +280,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])
@@ -462,7 +492,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))
@@ -476,6 +506,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])
@@ -656,7 +716,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))
@@ -670,6 +730,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])