Did you know ... Search Documentation:
Pack upsh -- prolog/upsh.pl
PublicShow source

Upsh 2.4

Upsh stands for Unix to Prolog shell. It is a Prolog program which can be used to run Prolog programs from the command line or as scripts.
It origianlly ran on three prolog engines without changes to the source code. Current versions are only tested on SWI-Prolog.

With version 2.*, Upsh has all the features I had envisaged and many which I just thought of on the way. It is also fairly stable.
The development has now been switched to SWI and upsh is also provided as an easy to install SWI pack.<br>

It is unlikely there will be any major releases in the future. I will of course get fixes on reported bugs or add features that are interesting.
For reporting a bug or feature requests contact me:


If you use Upsh for a while I would appreciate an email with the kind of scripts you using it with.

The pack has a single main predicate which creates an executable state that provides a convenient way of executing prolog scripts for the command line.
The state can be invoked by calling the created executable (upsh) on command line.
By default the upsh binary is placed in same directory as the swipl executable. Only tested on linux.

?- pack_install(upsh).

?- use_module(library(upsh)).

Create the executable.
?- upsh_make.


?- halt.

-- ask your shell to re-read its executables with something like: rehash

upsh say naku

%  /home/nicos/.rcpl compiled 0.00 sec, 8 clauses
% /home/nicos/bin/cline_upsh/say.pl compiled 0.00 sec, 5 clauses

lykos;upsh/scripts% upsh v

The executable will look into three places for scripts.

  • local directory
  • $HOME/bin/cline
  • PACK/scripts for any installed PACK

Upsh will also convert os friendly arguments to Prolog terms:

upsh say a=b
%  /home/nicos/.rcpl compiled 0.00 sec, 8 clauses
% /home/nicos/bin/cline_upsh/say.pl compiled 0.00 sec, 5 clauses

The executable takes a number of one letter flags:

upsh say p a=b
%  /home/nicos/.rcpl compiled 0.00 sec, 8 clauses

upsh say f p a=b

By default the executable looks into script say.pl for main/0, main/1, main/n, say/0, say/1, say/n and calls it with the appropriate number of arguments.

- nicos angelopoulos
- 2.3 2018/5/2
- 2.4 2018/12/10 simplified upsh_make/1 (no more shell call to build the executable).
directory for putting the executable in, defaults to the one holding swipl constructed from current_prolog_flag( home, Home ).
name of executable
- Nicos Angelopoulos
- 0.1 2017/06/03
- 0.2 2018/12/10

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 upsh_version(Arg1, Arg2)