arctic-hen7 / bonnie

Simple, cross-platform, and fast command aliases with superpowers.
MIT License
83 stars 6 forks source link

Multistage commands run each stage in a different shell #17

Closed arctic-hen7 closed 3 years ago

arctic-hen7 commented 3 years ago

Describe the bug Any command with multiple stages will have each of its stages executed in a different subshell.

Minimum reproducible configuration

version = "0.3.0"

[scripts]
test = [ "cd /tmp", "pwd" ]

Expected behavior The above example should print /tmp as the current directory, assuming that the two stages run in the same shell.

Actual behavior The above example will instead print the directory in which it was executed, as the commands run in different shells.

Runtime information Ubuntu 20.10, but this affects all systems.

arctic-hen7 commented 3 years ago

This is fine from the final schema's perspective, but Bones still uses an older variant of the schema with each stage being a different BonesCore. Fixing this would require a change to that logic, but that'd be beneficial anyway. Then it'll be a matter of figuring out how to run multiple commands in the same shell.

I'll start work on this.

arctic-hen7 commented 3 years ago

Okay, this will result in a syntax change. Users must now specify delimiters to use for multistage commands. The defaults will be && for all shells except PowerShell, which will use ;. This also allows the customization of the behavior of multistage commands (e.g. you could use || instead in BASH to execute only if the previous command failed).

arctic-hen7 commented 3 years ago

If that syntax is made optional though, with the reasonable default delimiter && (which works everywhere except Windows PowerShell I think), this can be a non-breaking change.