This library provides some basic (POSIX) shell commands defined in
Prolog, such as pwd and ls for situations
where there is no shell available or the shell output cannot be
captured. Note that in recent versions (since 10.1.13) the GUI frontend swipl-win
can capture process output on all supported platforms.
- shell
- Execute an interactive shell. Uses shell_command/1
to find a suitable shell.
The shell's exit status is not our business, so shell/0
succeeds whatever it is. Note that if the shell cannot be executed shell/2
raises an exception.
- shell_command(-Shell:atom)
- True when Shell is the preferred executable for running an
interactive shell. Used by shell/0.
The following options are tried to find a suitable shell command:
- The Prolog flag
shell
- The environment variable
%comspec% (Windows only)
- The environment variable
$SHELL
- The Prolog flag posix_shell
- Errors
existence_error(config, shell) if no suitable shell can be
found.
- cd
- cd(Dir)
- Change working directory
- pushd
- pushd(+Dir)
- popd
- dirs
- Manage the directory stack:
- pushd/1 is as cd/1,
pushing th old directory on a stack
- pushd/0 swaps the
current directory with the top of the stack
- popd/0 pops to the top
of the stack
- dirs/0 lists the
current directory and the stack.
- pwd
- Print current working directory
- ls
- ls(+Pattern)
- Listing similar to Unix
ls -F, flagging directories with /.
If the terminal supports it, Prolog source files are rendered as links
using the OSC 8 escape sequence. When using Epilog, clicking a Prolog
file opens it in the editor.
- [det]mv(+From,
+To)
- Move (Rename) a file. If To is a directory, From
is moved into the directory. Uses expand_file_name/2
on the From argument.
- [det]rm(+File)
- Remove (unlink) a file
- [det,multifile]file_style(++File,
=Style)
- True when File should be listed as a terminal hyperlink. The
default only links Prolog source files.
| Style | is either url to make a
hyperlink or a valid style argument for ansi_format/3. |
- cls
- CLear Screen. Emits ANSI control characters to clear the terminal.