Required position of passed source file when there are other options?

This is just to receive a confirmation about the behavior I’m seeing (because I couldn’t find any in the documentation).

A source file passed to swipl should come last if other command line options are present.

  • This did not work for me:
    swipl --on-error=halt (the flag was not set)
  • While this did:
    swipl --on-error=halt (file last, the flag was set)

Is this a fixed rule?

Yes. The overall commandline structure for running a file is

 swipl [prolog options] [ ...] [--] [application arguments]

Thus, in your first example --on-error=halt is handled as an application option. The optional -- after the file is needed if the first application argument is *.pl. You get the application arguments using the Prolog flag argv. See also library(main).