Did you know ... Search Documentation:
shell.pl -- Elementary shell commands
PublicShow source

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.

Source 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.

Source 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:
  1. The Prolog flag shell
  2. The environment variable %comspec% (Windows only)
  3. The environment variable $SHELL
  4. The Prolog flag posix_shell
Errors
- existence_error(config, shell) if no suitable shell can be found.
Source cd
Source cd(Dir)
Change working directory
Source pushd
Source pushd(+Dir)
Source popd
Source 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.
Source pwd
Print current working directory
Source ls
Source 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.
Source 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.
Source rm(+File) is det
Remove (unlink) a file
Source file_style(++File, =Style) is det[multifile]
True when File should be listed as a terminal hyperlink. The default only links Prolog source files.
Arguments:
Style- is either url to make a hyperlink or a valid style argument for ansi_format/3.
Source cls
CLear Screen. Emits ANSI control characters to clear the terminal.

Re-exported predicates

The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.

Source cd
Source cd(Dir)
Change working directory
Source pushd
Source pushd(+Dir)
Source popd
Source 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.
Source pushd
Source pushd(+Dir)
Source popd
Source 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.
Source pushd
Source pushd(+Dir)
Source popd
Source 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.
Source ls
Source 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.