You can execute code and scripts when you start ShiftLeft Ocular. This is useful if you find yourself copy and pasting the same code snippets into every ShiftLeft Ocular session.
To execute initialization code for one session, you can provide your input scripts with
--import, which allows to specify a comma-separated list of scripts:
echo 'def foo = 42' > scripts/myScript1.scecho 'def bar = 43' > scripts/myScript2.sc./ocular.sh --import scripts/myScript1.sc,scripts/myScript2.scocular> foores0: Int = 42ocular> barres1: Int = 42
To execute initialization code every time you start ShiftLeft Ocular, simply write it to a
.sc file in your
~/.shiftleft/ocular/ directory. A good convention is to use
~/.shiftleft/ocular/predef.sc, but Ocular will execute all
.sc files on every startup.
echo 'def foo = 42' > ~/.shiftleft/ocular/predef.sc./ocular.shocular> foores0: Int = 42
When you run ShiftLeft Ocular in non-interactive mode, you can specify a script file to execute. Refer to the article Using ShiftLeft in Interactive and Non-Interactive Modes for information.