Is it possible to invoke Mathematica's diff functionality from the command line?

前端 未结 1 622
野性不改
野性不改 2021-02-09 00:12

TortoiseSVN (as well as other Tortoise clients) include a script to diff notebook files in Mathematica. Diff functionality for Mathematica is implemented in the AuthorTools pac

相关标签:
1条回答
  • 2021-02-09 00:44

    Here's a simple example of producing the notebook diff using a Mathematica script.

    Save the following as diff.m

    Needs["AuthorTools`"]
    If[Length[$ScriptCommandLine]>=3, 
        {f1, f2} = $ScriptCommandLine[[{2,3}]], 
        {f1, f2} = {"one.nb", "two.nb"}]
    diff = FileNameJoin[{$TemporaryDirectory, "diff.nb"}]
    Put[NotebookDiff[f1, f2], diff]
    Run["Mathematica " <> diff]
    DeleteFile[diff]
    Exit[]
    

    Then call it from the command line using MathematicaScript -script diff.m "one.nb" "two.nb". This works on my system (Ubuntu 11.10, Mathematica 8.0.1) and should be platform independent. If you're using a version of Mathematica older than v8, then you'd have to use MathKernel -noprompt -run < diff.m instead of MathematicaScript and the default values for {f1, f2} will be used.

    0 讨论(0)
提交回复
热议问题