sophiakoulen / minishell

A simplified bash-like shell, with pipes, redirections and variable expansion.
4 stars 1 forks source link

print tree is back! #144

Closed znichola closed 1 year ago

znichola commented 1 year ago
minishell$ minitree '(a && b) || (c&&b) '
          .———a :
     .———&&
    |     `———b :
———||
    |     .———c :
     `———&&
          `———b :
minishell$ minitree '(a && b) || (c&&b) && (e||f&&(g||h))'
               .———a :
          .———&&
         |     `———b :
     .———||
    |    |     .———c :
    |     `———&&
    |          `———b :
———&&
    |          .———e :
    |     .———||
    |    |     `———f :
     `———&&
         |     .———g :
          `———||
               `———h :
minishell$ minitree '(a && b) ||( (c&&b) && (e||f&&(g||h)))'
          .———a :
     .———&&
    |     `———b :
———||
    |          .———c :
    |     .———&&
    |    |     `———b :
     `———&&
         |          .———e :
         |     .———||
         |    |     `———f :
          `———&&
              |     .———g :
               `———||
                    `———h :
minishell$ 
znichola commented 1 year ago

pretty sure it leaks like crazy for the trunk struct, but will have a look later.

znichola commented 1 year ago

Still need to fixup the print cmd but it's looks good.

minishell$ minitree '(echo hello world | <in shout >out ) && (ls | pwd | echo sdff >>this || git commit -m "this") && (printf "this %s" "that" || echo 1)'
          .——— echo hello world | shout | < in > out
     .———&&
    |    |     .——— ls | pwd | echo sdff | >> this
    |     `———||
    |          `——— git commit -m "this" |
———&&
    |     .——— printf "this %s" "that" |
     `———||
          `——— echo 1 |
minishell$ 
znichola commented 1 year ago

discussion moved to #145 pull request