0

In Sublimetext editor, we can specify custom build command using shell_cmd exec Target Options.

I want to add a subcommand within shell_cmd value. For Linux terminal commands, this can be done as outer-bin arg1 $(inner-command), where $(inner-command) provides the second argument for the outer-bin command.

I edit and run Tamarin models with Sublimetext. Some model files (e.g. LAK06-UK3.spthy) contain user-defined lemma (e.g. executable) and some implicit lemmas (e.g. Observational_equivalence). The default Tamarin command with --prove flag proves all user-defined and implicit lemmas. However, with the subcommand in the build system, I wish to pass only user-defined lemma. The build command including the subcommand for the LAK06-UK3.spthy could be:

tamarin-prover --diff LAK06-UK3.spthy $(python3 extract_lemma_cmd.py LAK06-UK3.spthy)

which translates to

tamarin-prover --diff LAK06-UK3.spthy --prove=executable

Any idea, how can I do this for Sublimetext custom build command?

  • Please [edit] your question and give an example of what you're trying to do. – MattDMo Feb 14 '23 at 18:15
  • added the case example – Mohit Kumar Jangid Feb 14 '23 at 19:20
  • The contents of `shell_cmd` is passed directly to the shell to eecute, so your example of `outer-bin args $(inner-command)` should work just fine; does it not? Something to note is that `$` is special in build systems, so you need to enter it as `\\$` so that Sublime passes it to the shell as `$` – OdatNurd Feb 14 '23 at 20:58

1 Answers1

1

You can use $() for command substitution, you just need to escape the $:

{
    "shell_cmd": "tamarin-prover --diff $file_name \\$(python3 extract_lemma_cmd.py $file_name)",
    "working_dir": "$file_path"
}

Make sure you use a double backslash \\$ for the escape.

Another solution is to use backticks:

{
    "shell_cmd": "tamarin-prover --diff $file_name `python3 extract_lemma_cmd.py $file_name`",
    "working_dir": "$file_path"
}

Please note that these shell_cmds will only work as-is on Linux and Mac. For Windows, they need to be run using bash -c, as the default shell on Windows is cmd.exe.

MattDMo
  • 100,794
  • 21
  • 241
  • 231