Skip to content

Fix alias expansion ( issue #711)

Roland Kovács requested to merge zen3ger/ion:issue-711 into master

This MR fixes alias expansion when it contains logical operators, piped commands or both.

Solution

Expand pipelines before run_pipeline by parsing the alias content into statements in execute_statement. If the alias is parsed into a Statement::Pipeline then merge the pipelines. Otherwise, try to break the pipeline into several executable chunks, mimicking the hand-replaced command, i.e.:

$ cat ion/Cargo.toml | grep '=' | wc -l && echo 'Number of matches found'
37
Number of matches found

$ alias search_eq = "grep '=' | wc -l && echo 'Number of matches found'"
$ cat ion/Cargo.toml | search_eq
37
Number of matches found
Note:

It only works with quoted commands.

Closes #711 (closed)

Edited by Roland Kovács

Merge request reports