Skip to content

Conversation

gnodet
Copy link
Member

@gnodet gnodet commented May 7, 2025

Description

This PR fixes issue #1232 by making the command execution order consistent in the method.

Problem

In most methods in , the order of command execution checking is:

  1. First check custom registries via
  2. Then check scripts via
  3. Finally check local commands via

However, in the method, the order was different:

  1. First check local commands via
  2. Then check custom registries via
  3. Finally check scripts via

This inconsistency made it impossible to override built-in commands like "exit" and "clear" with custom implementations, as the local commands were always checked first in the method.

Solution

Modified the method to make the command execution order consistent with other methods in the class:

  • Changed the order to check custom registries first, then scripts, and finally local commands
  • This allows overriding built-in commands with custom implementations

Testing

Added a test class that demonstrates the ability to override built-in commands with custom implementations. The test verifies that our fix works correctly.

Fixes #1232

…ecute method

This fixes issue jline#1232 by changing the order of command execution checking in the execute method to be consistent with other methods in the class. Now it checks custom registries first, then scripts, and finally local commands, which allows overriding built-in commands like 'exit' and 'clear' with custom implementations.

Added a test that demonstrates the ability to override built-in commands with custom implementations.
@gnodet gnodet merged commit 8ea92ce into jline:master May 7, 2025
9 checks passed
@gnodet gnodet added this to the 3.29.1 milestone May 7, 2025
@gnodet gnodet added the bug label May 7, 2025
@gnodet gnodet deleted the fix-1232-command-execution-order branch May 7, 2025 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent behaviour in SystemRegistryImpl
1 participant