@SuppressWarnings(value="deprecation")
class Main
extends Object
Boots and runs the interactive groovysh console.
| Modifiers | Name | Description |
|---|---|---|
protected static class |
Main.ExtraConsoleCommands |
Registers the extra console commands that augment the interactive shell. |
| Modifiers | Name | Description |
|---|---|---|
static String |
INTERPRETER_MODE_PREFERENCE_KEY |
Preference key that controls whether groovysh starts in interpreter mode. |
| Constructor and description |
|---|
Main() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
static Path |
createOwnerOnlyStateFile(Path file)Ensures a file under the user state directory exists and is readable only by its owner. |
|
static Path |
getUserStateDirectory()Returns the user state directory used by groovysh for persisted files. |
|
static void |
main(String[] args)Launches groovysh as a standalone JVM process. |
|
static int |
start(Map<String, ?> initialBindings, String[] args)Programmatic entry point for embedding groovysh. |
|
static int |
start(String[] args)Programmatic entry point for embedding groovysh. |
|
static Path |
tightenStateFile(Path file)Restricts an existing state file to its owner when it is currently more permissive, and does nothing at all when the file is absent. |
Preference key that controls whether groovysh starts in interpreter mode.
Ensures a file under the user state directory exists and is readable only by its owner.
These files record what was typed at the shell and the values it held, so on a shared host they should not be left at whatever the ambient umask happens to permit. A file that already exists is tightened only when it is currently more permissive than owner-only, so a deliberately-chosen mode is left alone. Failing to adjust permissions is not fatal: the file is still usable, and the shell should not refuse to start over it.
file - the state fileReturns the user state directory used by groovysh for persisted files.
Launches groovysh as a standalone JVM process.
args - command-line argumentsProgrammatic entry point for embedding groovysh.
args - CLI-like arguments (same as main(String[])).initialBindings - binding variables for the GroovyEngineProgrammatic entry point for embedding groovysh.
args - CLI-like arguments (same as main(String[])).Restricts an existing state file to its owner when it is currently more permissive, and does nothing at all when the file is absent.
JLine warns about an over-permissive history file rather than changing it, so as not to surprise the user. This is the one place groovysh goes further: the file records what was typed at a shell prompt, the warning is easy to miss in a log, and the directory it lives in belongs to groovysh. A mode stricter than owner-only is still left alone.
file - the state fileCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.