Answer stability round 1: 1 🔴, 2 🟡; end the command at a glued &< and pin each redirect form
This commit is contained in:
@@ -77,12 +77,18 @@ class Commits(unittest.TestCase):
|
||||
|
||||
def test_a_redirect_keeps_its_command_s_words_together(self):
|
||||
self.assertEqual(segments("echo hi > f arg"), [["echo", "hi", "arg"]])
|
||||
self.assertEqual(committed("git > /tmp/x commit -m hi"), [Commit("/r", ["hi"], False)])
|
||||
for redirect in [">", ">>", "<", "<<<", "<>", ">&", "<&", ">|", "&>", "&>>"]:
|
||||
with self.subTest(redirect):
|
||||
self.assertEqual(committed(f"git {redirect} /tmp/x commit -m hi"), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(committed("git commit >&2 -m hi 2>&1"), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(committed("> out git commit -m hi"), [Commit("/r", ["hi"], False)])
|
||||
|
||||
def test_a_command_after_a_redirect_and_a_separator_is_still_apart(self):
|
||||
def test_a_separator_glued_to_a_redirect_still_ends_the_command(self):
|
||||
self.assertEqual(segments("echo a > f; echo b | cat &> g\nls"), [["echo", "a"], ["echo", "b"], ["cat"], ["ls"]])
|
||||
for command in ["echo a &</dev/null git commit -m hi", "echo a;>f git commit -m hi", "tee >(true) git commit -m hi"]:
|
||||
with self.subTest(command):
|
||||
self.assertEqual(committed(command), [Commit("/r", ["hi"], False)])
|
||||
self.assertEqual(segments("diff <(a) b"), [["diff"], ["b"]])
|
||||
|
||||
|
||||
class CommandBreaches(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user