# Swipl comman line: specifying source file name

**URL:** <https://swi-prolog.discourse.group/t/swipl-comman-line-specifying-source-file-name/866>\
**Category:** Help!\
**Created:** [June 27, 2019, 8:40am UTC](https://swi-prolog.discourse.group/t/swipl-comman-line-specifying-source-file-name/866 "2019-06-27T08:40:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adimetrius](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@adimetrius](https://swi-prolog.discourse.group/u/adimetrius)\
**Post date:** [June 27, 2019, 8:40am UTC](https://swi-prolog.discourse.group/t/swipl-comman-line-specifying-source-file-name/866/1 "2019-06-27T08:40:57Z")

</div>

I was trying to run swipl command line as follows:  
**swipl --quiet -g do -t halt /somedir/input**  
It’s error message was  
**ERROR: -g do: catch/3: Undefined procedure: do/0**  
Well, do was most certainly in my source file.  
Took me quite some time of experimenting with encodings ('cause I need the source to be in UTF-8) - only to figure out that the problem is fixed by adding .pl to the file name and the command line. Works as follows:  
**swipl --quiet -g do -t halt /somedir/input.pl**  
I double-checked with man swipl and [swi-prolog.org](http://swi-prolog.org) - there is no mention (that I could find) of the need for .pl extension. Am I looking in the wrong direction, or is this a minor bug to be reported? I think silently ignoring a command-line parameter is a bug. I came across my solution accidentally. And it cost me time. Hope this will help someone else save their time.

P.S. removing --quiet did not make swipl any more verbose.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [June 27, 2019, 9:50am UTC](https://swi-prolog.discourse.group/t/swipl-comman-line-specifying-source-file-name/866/2 "2019-06-27T09:50:06Z")

</div>

In the [manual](https://www.swi-prolog.org/pldoc/man?section=cmdline) we find:

> If the options are followed by one or more Prolog file names (i.e., names with extension `.pl` , `.prolog` or (on Windows) the user preferred extension registered during installation), these files are loaded.

Which doesn’t really invalidate your comment. Clearly it is hard to find this. Warnings are a bit unclear. The command line syntax has been changed several times ☹ It (roughly) consists of three components, all of which may be empty: (1) options that modify Prolog’s behavior (quiet, stack limits, etc), (2) source files to load and (3) options for the application to pick up using the `argv` Prolog flag.

Notably (2) can be empty if we call built-in predicates, use `-g` to load files or rely on an autoload library.

One alternative might be that the first non-Prolog option argument is either `--` or a file name to be loaded. Note that for handling `#!`, we particularly want `swipl source-file application option ...` to work.

---

<div class="post-metadata">

**Author:** ![adimetrius](https://avatars.discourse-cdn.com/v4/letter/a/e79b87/32.png) [@adimetrius](https://swi-prolog.discourse.group/u/adimetrius)\
**Post date:** [June 27, 2019, 10:02am UTC](https://swi-prolog.discourse.group/t/swipl-comman-line-specifying-source-file-name/866/3 "2019-06-27T10:02:13Z")

</div>

jan, thank you! My bad, I overlooked it in the manual. But I would still suggest that an error message or at least a warning be printed if swipl finds smth on the command line (before "-- ") that it cannot interpret. What do you think?

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [June 27, 2019, 10:44am UTC](https://swi-prolog.discourse.group/t/swipl-comman-line-specifying-source-file-name/866/4 "2019-06-27T10:44:26Z")

</div>

Before `--` would break the common `swipl script arg ...`. What **might** work is, as I said, demand the Prolog to be followed by a script or `--`. Anyone sees (compatibility) problems with that?
