From 69fc45061b9b8219ce02a2e32fc7c70bfea78a44 Mon Sep 17 00:00:00 2001 From: Tilman Kranz Date: Sun, 21 Aug 2022 15:47:44 +0200 Subject: [PATCH] add test, escape spaces in output --- README.md | 14 ++++++++------ test/01.sh | 26 ++++++++++++++++++++++++++ trie.py | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) create mode 100755 test/01.sh mode change 100644 => 100755 trie.py diff --git a/README.md b/README.md index f7786f0..de7ca75 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,14 @@ cpn("aa", "ab", "abc", "abd") = "a{a,b{,c,d}}" cpn("a", "ab", "abc") = "{a{,b{,c}}}" ``` -*Note:* For the sake of reasoning, strings containing the CPN’s reserved characters {, } and , shall be considered invalid input. In a practical implementation, a syntax for „escaping“ these reserved characters should be available. For example, in the reference implementation, the print_trie() function inserts a backslash character \ in front of every literal {, , and }. +*Note:* For the sake of reasoning, strings containing the CPN’s reserved +characters `{`, `}` and , shall be considered invalid input. In a practical +implementation, a syntax for „escaping“ these reserved characters should be +available. For example, in the reference implementation, the `print_trie()` +function inserts a backslash character `\` in front of every literal `{`, `,` +and `}`; additionally, every space character ` ` is escaped, because it +acts as a word separator in GNU Bourne Again Shell and other interpreters +of brace expansion syntax. ## 2 Implementation @@ -95,8 +102,3 @@ Expected output: a ab abc ``` -## Appendix A: References - -* [Initial announcement](https://tk-sls.de/wp/6071) -* [Update](https://tk-sls.de/wp/6144) -* [Git repository](https://tk-sls.de/gitlab/tilman/trie) diff --git a/test/01.sh b/test/01.sh new file mode 100755 index 0000000..fad4667 --- /dev/null +++ b/test/01.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +dir=$(dirname "$(readlink -f "$0")") +trie="$dir/../trie.py" + +read -r -d '' input <