github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/pkg/pogosh/ast.go (about) 1 // Copyright 2020 the u-root Authors. All rights reserved 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package pogosh 6 7 type command interface { 8 exec(*State) 9 } 10 11 // ! cmd 12 type not struct { 13 cmd command 14 } 15 16 // cmd1 && cmd2 17 type and struct { 18 cmd1 command 19 cmd2 command 20 } 21 22 // cmd1 || cmd2 23 type or struct { 24 cmd1 command 25 cmd2 command 26 } 27 28 // cmd & 29 type async struct { 30 cmd command 31 } 32 33 // cmds[0]; cmds[1]; ... cmds[n-1]; 34 type compoundList struct { 35 cmds []command 36 } 37 38 // cmds[0] | cmds[1] | ... | cmds[n-1] 39 type pipeline struct { 40 cmds []command 41 } 42 43 // ( cmd ) 44 type subshell struct { 45 cmd command 46 } 47 48 // for name in wordlist; do cmd; done 49 type forClause struct { 50 name []byte 51 wordlist [][]byte 52 cmd command 53 } 54 55 // case word in cases esac 56 type caseClause struct { 57 word []byte 58 cases []caseItem 59 } 60 61 // pattern ) cmd 62 type caseItem struct { 63 pattern []byte 64 cmd command 65 } 66 67 // if cmdPred then cmdThen else cmdElse done 68 type ifClause struct { 69 cmdPred command 70 cmdThen command 71 cmdElse command 72 } 73 74 // while cmdPred; do cmd; done 75 type whileClause struct { 76 cmdPred command 77 cmd command 78 } 79 80 // name() cmd 81 type function struct { 82 name []byte 83 cmd command 84 } 85 86 // name args... redirects... 87 type simpleCommand struct { 88 name []byte 89 args [][]byte 90 redirects []redirect 91 } 92 93 // ioOp filename 94 type redirect struct { 95 ioOp []byte 96 filename []byte 97 }