CodeRunner defines a number of environment variables, prefixed by CR_, that are useful in compile scripts, run commands, debugger scripts, etc. Some important environment variables are listed below:
$CR_FILENAME The name of the file being run in the current working directory (i.e. not an absolute path).$CR_FILE The absolute path of the file being run.$CR_TMPDIR CodeRunner temporary directory.$CR_SUGGESTED_OUTPUT_FILE Contains an absolute path to which the compiler may write an output/binary file. The path may refer to a file in a temporary directory or in the same directory as the file being run, depending on user preferences. When running diagnostics, the file is in a temporary directory. The suggested output file has no file extension.$CR_DEBUGGER_DIR Set to the debugger directory (containing debugger.sh and supporting files) when the current run is a debug run, otherwise unset.$CR_DEBUGGING Set to a non-empty value when the current run is a debug run, otherwise unset.$CR_DEVELOPER_DIR Contains an absolute path to CodeRunner's Developer directory.$CR_DIAGNOSTICS When set to a non-empty value, the current run is a diagnostics run.$CR_DIAGNOSTICS_DIR When the current run is a diagnostics run, contains an absolute path to the diagnostics directory, where supporting files for generating diagnostics may be stored.$CR_LANGUAGE_DIR Contains an absolute path to the directory of the current language configuration.$CR_SCRIPTS_DIR Contains an absolute path to the Scripts subdirectory of the current language configuration. Equal to $CR_LANGUAGE_DIR/Scripts.$CR_ENCODING The character set encoding code for the file being run.$CR_ENCODING_NAME The character set encoding name (IANA) for the file being run.$CR_INPUT When set, contains an absolute path to a temporary file containing the input to the file being run, as specified in Run Settings.$CR_RUNID A number that uniquely identifies the current run job. Suitable for use as a TCP/UDP port, or as part of a temporary file name.$CR_RUN_COMMAND The run command of the current file or language configuration.$CR_UNSAVED_DIR Contains the absolute path of the directory where CodeRunner stores unsaved documents. This path may change based on user preferences.$CR_SANDBOXED When set to a non-empty value, indicates that CodeRunner is operating in sandboxed environment.For a full list of the available variables, use the env shell command in a compile script:
#!/bin/sh
env | grep CR_
exit 1
These environment variables are only available in run commands. When they appear in a run command, they are automatically quoted before the run command is executed.
$filename Equivalent to $CR_FILENAME$compiler Contains the last line of output (stdout) from a successful run (exit status 0) of the compile script.