---
source: brush-parser/src/parser/tests/complex.rs
expression: "ParseResult { input, result: &result }"
---
ParseResult(
  input: "myfunc() {\n    if [[ -z \"$1\" ]]; then\n        echo \"No argument\"\n        return 1\n    fi\n    echo \"Got: $1\"\n}",
  result: Program(
    complete_commands: [
      CompoundList([
        CompoundListItem(AndOrList(
          first: Pipeline(
            seq: [
              Function(FunctionDefinition(
                fname: Word(
                  value: "myfunc",
                  loc: "[location]",
                ),
                body: FunctionBody(BraceGroup(BraceGroupCommand(
                  list: CompoundList([
                    CompoundListItem(AndOrList(
                      first: Pipeline(
                        seq: [
                          Compound(IfClause(IfClauseCommand(
                            condition: CompoundList([
                              CompoundListItem(AndOrList(
                                first: Pipeline(
                                  seq: [
                                    ExtendedTest(ExtendedTestExprCommand(
                                      expr: UnaryTest(StringHasZeroLength, Word(
                                        value: "\"$1\"",
                                        loc: "[location]",
                                      )),
                                      loc: "[location]",
                                    ), None),
                                  ],
                                ),
                              ), Sequence),
                            ]),
                            then: CompoundList([
                              CompoundListItem(AndOrList(
                                first: Pipeline(
                                  seq: [
                                    Simple(SimpleCommand(
                                      word_or_name: Some(Word(
                                        value: "echo",
                                        loc: "[location]",
                                      )),
                                      suffix: Some(CommandSuffix([
                                        Word(Word(
                                          value: "\"No argument\"",
                                          loc: "[location]",
                                        )),
                                      ])),
                                    )),
                                  ],
                                ),
                              ), Sequence),
                              CompoundListItem(AndOrList(
                                first: Pipeline(
                                  seq: [
                                    Simple(SimpleCommand(
                                      word_or_name: Some(Word(
                                        value: "return",
                                        loc: "[location]",
                                      )),
                                      suffix: Some(CommandSuffix([
                                        Word(Word(
                                          value: "1",
                                          loc: "[location]",
                                        )),
                                      ])),
                                    )),
                                  ],
                                ),
                              ), Sequence),
                            ]),
                            loc: "[location]",
                          )), None),
                        ],
                      ),
                    ), Sequence),
                    CompoundListItem(AndOrList(
                      first: Pipeline(
                        seq: [
                          Simple(SimpleCommand(
                            word_or_name: Some(Word(
                              value: "echo",
                              loc: "[location]",
                            )),
                            suffix: Some(CommandSuffix([
                              Word(Word(
                                value: "\"Got: $1\"",
                                loc: "[location]",
                              )),
                            ])),
                          )),
                        ],
                      ),
                    ), Sequence),
                  ]),
                  loc: "[location]",
                )), None),
              )),
            ],
          ),
        ), Sequence),
      ]),
    ],
  ),
)
