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 a specific session, include in your input scripts the flag
--import, which allows you 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 the initialization code to a
.sc file in your
A good convention is to use
~/.shiftleft/ocular/predef.sc, but ShiftLeft Ocular executes 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.