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 f1.pl --on-error=halt (the flag was not set)
  • While this did:
    swipl --on-error=halt f1.pl (file last, the flag was set)

Is this a fixed rule?

Yes. The overall commandline structure for running a file is

 swipl [prolog options] file.pl [file2.pl ...] [--] [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).