Can both shell: and run: be used in a single rule?

Viewed 110

I'm fairly sure the answer to the title is 'no'. However, I'd like some suggestions because I'm not able to gracefully solve this seemingly simple problem. Here's what I'd like to do in a single rule that works unmodified in Linux and Windows:

  1. Run a shell command that produces a certain directory as part of its output. The name of the shell command is identical in Linux and Windows, so it works in both places unmodified.
  2. Rename the directory using pathlib or some other Python module so it works transparently in Linux and Windows.

That's it!

Here's what I have come up with already which I don't want to do because they seem clunky:

  1. Run the executable and do the rename in a shell. For this I need to make custom command lines based on which platform I'm on. (Linux 'mv' vs. Windows 'rename') Yuck.
  2. Make another rule that runs automatically and does the rename after this rule. This is a little better but still doesn't seem "right".

I'll bet there's an elegant solution, but what is it?

1 Answers

Yes. There are two ways to execute a command in the shell, depending on the use case:

  • A shell: line in a rule. Can't be combined with other Python code.
  • A shell() command that can be used with other Python code in a rule's run: line
Related