import shell // TODO: pass all tests from https://github.com/python/cpython/blob/main/Lib/test/test_shlex.py fn test_quote() { assert shell.quote("janna d'arc") == '\'janna d\'"\'"\'arc\'' } fn test_join() { assert shell.join(['sh', '-c', 'hostname -f']) == "sh -c 'hostname -f'" } fn test_split() { assert shell.split("sh -c 'hostname -f'") == ['sh', '-c', 'hostname -f'] assert shell.split('sh -c hostname') == ['sh', '-c', 'hostname'] assert shell.split('hostname -f # some comment') == ['hostname', '-f', '#', 'some', 'comment'] assert shell.split('hostname -f # some comment', comments: true) == ['hostname', '-f'] assert shell.split('grep -rn "#"') == ['grep', '-rn', '#'] assert shell.split('grep -rn "#"', comments: true) == ['grep', '-rn', '#'] // FIXME: both assertions fails // s := 'grep -rn hello # search hello // awk --help // '.trim_indent() // assert shell.split(s) == ['grep', '-rn', 'hello', '#', 'search', 'hello', 'awk', '--help'] // assert shell.split(s, comments: true) == ['grep', '-rn', 'hello', 'awk', '--help'] }