Upsh 2.6

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 origianlly ran on three prolog engines: SICStus, SWI and Yap without changes to the source code. Later version (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. The development now has switched to SWI and upsh is also provided as an easy to install SWI pack. It is unlikely there will be any major releases in the future. I will of course fix any bugs reported 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. Install:

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

> cd *installed_packs_dir*/upsh/scripts
-- 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/ compiled 0.00 sec, 5 clauses

As of version 2.5 you no longer have to cd into 
cd *installed_packs_dir*/upsh/scripts
Instead upsh will look into the scripts directory of all installed packs. It also looks into $HOME/bin/cline_upsh/. From 2.5 it will also load any single .pl file without giving its name on the command line. So if you local dir looks like data.csv
> upsh
Will load and call the first existing predicate from the following:
testo/1, testo/0, main/1, main/0.
> cd $HOME
> upsh say naku
% /home/nicos/.local/share/swi-prolog/pack/upsh/scripts/ compiled 0.00 sec, 6 clauses
> upsh v upsh_exec(upsh(2:6:0),swi(9:1:15),built_on(2023/11/20,11:58:29)) The executable will look at $HOME/bin/cline for scripts, so you use it for scripts that operate on os objects. It will also convert os friendly arguments to Prolog terms: > upsh say a=b > upsh say a=b % /home/nicos/.rcpl compiled 0.00 sec, 8 clauses % /home/nicos/bin/cline_upsh/ compiled 0.00 sec, 5 clauses a(b)
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
> upsh h 
to get the help screen. By default the executable looks into script for main/0, main/1, main/n, say/0, say/1, say/n and calls it with the appropriate number of arguments.


The manual, which is effectively an extended version of my WLPE 2004 paper is also in doc/ in the above .tgz file. However, is now quite outdated.

Last update 2023/11/20
Nicos Angelopoulos