github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/gen/parser/pipes_doc.yaml (about) 1 - DocumentID: pipe-arrow 2 Title: >- 3 `->` Arrow Pipe 4 CategoryID: parser 5 Summary: >- 6 Pipes STDOUT from the left hand command to STDIN of the right hand command 7 Description: |- 8 This token behaves much like pipe would in Bash or similar shells. It passes 9 STDOUT along the pipeline while merging STDERR stream with the parents STDERR 10 stream. 11 12 `->` differs from `|` in the interactive terminal where it produces different 13 autocompletion suggestion. It returns a list of "methods". That is, commands 14 that are known to support the output type of the previous command. `->` helps 15 with the discovery of commandline tools. 16 17 In shell scripts, `->` and `|` can be used interchangeably. 18 Examples: |- 19 ``` 20 » out Hello, world! -> regexp s/world/Earth/ 21 Hello, Earth! 22 23 » out Hello, world!->regexp s/world/Earth/ 24 Hello, Earth! 25 ``` 26 27 In following example the first command is writing to STDERR rather than STDOUT 28 so `Hello, world!` doesn't get pipelined and thus isn't affected by `regexp`: 29 30 ``` 31 » err Hello, world! -> regexp s/world/Earth/ 32 Hello, world! 33 ``` 34 Detail: |- 35 Related: 36 - pipe-posix 37 - pipe-generic 38 - namedpipe 39 - pipe-err 40 - pipeline 41 - out 42 - err 43 - regexp 44 45 46 47 - DocumentID: pipe-err 48 Title: >- 49 `?` STDERR Pipe 50 CategoryID: parser 51 Summary: >- 52 Pipes STDERR from the left hand command to STDIN of the right hand command (DEPRECATED) 53 Description: |- 54 This token swaps the STDOUT and STDERR streams of the left hand command. 55 56 Please note that this token is only effective when it is prefixed by white 57 space. 58 59 > This feature has been deprecated. Please use `<err> <!out>` instead. For example: 60 > ``` 61 > command <err> <!out> parameter-1 parameter-2 -> next-command parameter-1 62 > ``` 63 Examples: |- 64 ``` 65 » err Hello, world! ? regexp s/world/Earth/ 66 Hello, Earth! 67 ``` 68 69 In following example the first command is writing to STDOUT rather than STDERR 70 so `Hello, world!` doesn't get pipelined and thus isn't affected by `regexp`: 71 72 ``` 73 » out Hello, world! ? regexp s/world/Earth/ 74 Hello, world! 75 ``` 76 77 In following example the STDERR token isn't whitespace padded so is treated 78 like any ordinary printable character: 79 80 ``` 81 » err Hello, world!? regexp s/world/Earth/ 82 Hello, world!? regexp s/world/Earth/ 83 ``` 84 Detail: |- 85 Related: 86 - pipe-arrow 87 - pipe-generic 88 - namedpipe 89 - pipe-posix 90 - pipeline 91 - out 92 - err 93 - regexp 94 95 96 97 - DocumentID: pipe-generic 98 Title: >- 99 `=>` Generic Pipe 100 CategoryID: parser 101 Summary: >- 102 Pipes a reformatted STDOUT stream from the left hand command to STDIN of the 103 right hand command 104 Description: |- 105 This token behaves much like the `|` pipe would except it injects `format 106 generic` into the pipeline. The purpose of a formatted pipe is to support 107 piping out to external commands which don't support Murex data types. For 108 example they might expect arrays as lists rather than JSON objects). 109 Examples: |- 110 ``` 111 » ja [Mon..Wed] => cat 112 Mon 113 Tue 114 Wed 115 ``` 116 117 The above is literally the same as typing: 118 119 ``` 120 » ja [Mon..Wed] -> format generic -> cat 121 Mon 122 Tue 123 Wed 124 ``` 125 126 To demonstrate how the previous pipeline might look without a formatted pipe: 127 128 ``` 129 » ja [Mon..Wed] -> cat 130 ["Mon","Tue","Wed"] 131 132 » ja [Mon..Wed] | cat 133 ["Mon","Tue","Wed"] 134 135 » ja [Mon..Wed] 136 [ 137 "Mon", 138 "Tue", 139 "Wed" 140 ] 141 ``` 142 Detail: |- 143 Related: 144 - pipe-arrow 145 - pipe-posix 146 - namedpipe 147 - pipe-err 148 - pipeline 149 - ja 150 - format 151 152 153 154 - DocumentID: pipe-posix 155 Title: >- 156 `|` POSIX Pipe 157 CategoryID: parser 158 Summary: >- 159 Pipes STDOUT from the left hand command to STDIN of the right hand command 160 Description: |- 161 This token behaves much like pipe would in Bash or similar shells. It passes 162 STDOUT along the pipeline while merging STDERR stream with the parents STDERR 163 stream. 164 165 It can be used interchangeably with the arrow pipe, `->`, in shell scripts. 166 Examples: |- 167 ``` 168 » out Hello, world! | regexp s/world/Earth/ 169 Hello, Earth! 170 171 » out Hello, world!|regexp s/world/Earth/ 172 Hello, Earth! 173 ``` 174 175 In this example the first command is writing to STDERR rather than STDOUT so 176 `Hello, world!` doesn't get pipelined and thus isn't affected by `regexp`: 177 178 ``` 179 » err Hello, world! | regexp s/world/Earth/ 180 Hello, world! 181 ``` 182 #Tests: |- 183 # ```go 184 # {{ include "lang/parser_docs/pipeposix_test.go" }} 185 # ``` 186 Detail: |- 187 Related: 188 - pipe-arrow 189 - pipe-generic 190 - namedpipe 191 - pipe-err 192 - pipeline 193 - out 194 - err 195 - regexp 196 197 198 199 - DocumentID: pipe-append 200 Title: >- 201 `>>` Append Pipe 202 CategoryID: parser 203 Summary: >- 204 Redirects STDOUT to a file and append its contents 205 Description: |- 206 This is used to redirect the STDOUT of a command and append it to a file. If 207 that file does not exist, then the file is created. 208 209 This behaves similarly to the [Bash (et al) token](https://www.gnu.org/software/bash/manual/bash.html#Appending-Redirected-Output) 210 except it doesn't support adding alternative file descriptor numbers. Instead 211 you will need to use named pipes to achieve the same effect in Murex. 212 Examples: |- 213 ``` 214 » out "Hello" >> example.txt 215 » out "World!" >> example.txt 216 » open example.txt 217 Hello 218 World! 219 ``` 220 Detail: |- 221 This is just syntactic sugar for `-> >>`. Thus when the parser reads code like 222 the following: 223 224 ``` 225 echo "foobar" >> example.txt 226 ``` 227 228 it will compile an abstract syntax tree which would reflect the following code 229 instead: 230 231 ``` 232 echo "foobar" | >> example.txt 233 ``` 234 235 ### Truncating a file 236 237 To truncate a file (ie overwrite its contents) use `|>` instead. 238 Related: 239 - pipe-arrow 240 - pipe-posix 241 - namedpipe 242 - pipe-err 243 - pipeline 244 - ja 245 - greater-than-greater-than 246 - greater-than