Upsh 3.0


Upsh stands for Unix to Prolog shell. The library has facilities to create a Prolog saved state executatle which can be used to run Prolog programs from the command line or as scripts. It originally ran on three prolog engines: SICStus, SWI and Yap without changes to the source code. Later versions (2 onwards), 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 and actively maintained. The development now has switched to SWI and upsh is also provided as an easy to install SWI pack. I will of course fix any bugs reported or add features that are interesting. For reporting a bug or feature requests

If you use Upsh for a while I would appreciate an email with the kind of scripts you using it with (this is how to contact me).

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. Install:

?- pack_install(upsh).
Load the pack.
?- use_module(library(upsh)).
Create the executable.
?- upsh_make.
To test.
?- halt.

> cd *installed_packs_dir*/upsh/scripts
-- ask your shell to re-read its executables with something like: rehash
> upsh say naku
% /home/nicos/bin/cline_upsh/say.pl compiled 0.00 sec, 5 clauses
naku

From v2.5 you can also do the following

 
> cd $HOME
> upsh say naku
% /home/nicos/.local/share/swi-prolog/pack/upsh/scripts/say.pl compiled 0.00 sec, 6 clauses
naku
To get the version of upsh and SWI-Prolog with which the upsh executable was build:
 
> upsh v
upsh_exec(upsh(2:6:0),swi(9:1:15),built_on(2023/11/20,11:58:29))
Upsh provides a number of ways for locating scripts and guessing scripts, see documentation below. It will also convert os friendly arguments to Prolog terms: > upsh say a=b > upsh say a=b % /home/nicos/bin/cline_upsh/say.pl compiled 0.00 sec, 5 clauses a(b)
The executable takes a number of one letter flags:
> upsh say p a=b
a(b)

> upsh say f p a=b
a(b)
Use
> upsh h 
to get the help message. By default the executable looks into a script like say.pl for say/0, say/1, say/n, main/0, main/1, main/n and calls it with the appropriate number of arguments. Typically say/1 is defined which will take as input a list of all arguments

Resources

The original manual, which is effectively an extended version of my WLPE 2004 paper is also in doc/upsh-manual.ps in the above .tgz file. However, is now quite outdated. The best source of acurate information is the plDoc generated from the sources (upsh.html


Last update 2026/3/9
Nicos Angelopoulos