Fixing some review remarks

This commit is contained in:
Yannick Jadoul
2020-05-06 23:57:33 +02:00
parent 575e229514
commit 891e2dd6aa
4 changed files with 11 additions and 14 deletions
+4 -4
View File
@@ -1,7 +1,7 @@
import shlex
import subprocess
from typing import Dict, List, NamedTuple, Optional
from typing import Dict, NamedTuple
import bashlex # type: ignore
@@ -45,7 +45,7 @@ def evaluate_word_node(node: bashlex.ast.node, context: NodeExecutionContext) ->
word_start = node.pos[0]
word_end = node.pos[1]
word_string = context.input[word_start:word_end]
letters: List[Optional[str]] = list(word_string)
letters = list(word_string)
for part in node.parts:
part_start = part.pos[0] - word_start
@@ -53,12 +53,12 @@ def evaluate_word_node(node: bashlex.ast.node, context: NodeExecutionContext) ->
# Set all the characters in the part to None
for i in range(part_start, part_end):
letters[i] = None
letters[i] = ''
letters[part_start] = evaluate_node(part, context=context)
# remove the None letters and concat
value = ''.join(l for l in letters if l is not None)
value = ''.join(letters)
# apply bash-like quotes/whitespace treatment
return ' '.join(word.strip() for word in shlex.split(value))