Answer prose round 1: 0 🔴, 4 🟡; fix this_chunks's and segments's cases, move the decision's validity to its first paragraph, name ladder.py and reflow the help, trim the README sentence

This commit is contained in:
2026-10-22 01:03:03 +02:00
parent b78accf55a
commit 9e4aebb3ff
7 changed files with 111 additions and 77 deletions
+3 -1
View File
@@ -29,12 +29,14 @@ def simple_commands(command: str, cwd: str, home: str) -> list[Simple]:
def segments(command: str) -> list[list[str]]:
"""The command's simple commands as lists of words, split at ; & | ( ) and line breaks. Shell forms it does not parse:
"""The command's simple commands as lists of words, split at ; & | ( ) < > and line breaks, without redirect targets. Shell forms it does not parse:
- a quoted string is one word, so `bash -c "git commit"` and `echo "$(git commit)"` hide the inner command;
- a backtick substitution stays inside its words, while `$(git commit)` outside quotes splits into the `$` and a command of its own;
- a keyword or a brace opens its command's words, so `then git commit` reads as the command `then`;
- a redirect splits a command in two, so `git > out commit` reads as `git` and `commit`;
- `<(...)` and `<<<` read as redirects, so the word after them is dropped as the target;
- a file descriptor before a redirect, as in `2>&1`, stays a word;
- a heredoc's body is dropped;
- variables, aliases and functions are not expanded;
- a line with an unbalanced quote yields nothing."""
text = uncommented(HEREDOC.sub(lambda heredoc: heredoc.group(0).split("\n", 1)[0], command))