
shell.pl -- Elementary shell commands
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
- The Prolog flag
cd
cd(Dir)- Change working directory
pushd
pushd(+Dir)
popd
dirs- Manage the directory 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.
mv(+From, +To) is det- Move (Rename) a file. If To is a directory, From is moved into the directory. Uses expand_file_name/2 on the From argument.
rm(+File) is det- Remove (unlink) a file
file_style(++File, =Style) is det[multifile]- True when File should be listed as a terminal hyperlink. The default only links Prolog source files.
cls- CLear Screen. Emits ANSI control characters to clear the terminal.
Undocumented predicates
The following predicates are exported, but not or incorrectly documented.