Skip to content

Conversation

Copy link

Copilot AI commented Jan 25, 2026

📥 Pull Request

✨ Description of new changes

Users can now use shell pipes in interactive mode, matching command-line behavior:

fab:/$ ls | grep Report
fab:/$ ls | grep test | head -5
fab:/$ ls | wc -l

Implementation:

  • _find_pipe_position() - Locates first unquoted pipe, respecting quotes and escapes
  • _pipe_to_shell() - Pipes captured output through shell command via subprocess.run
  • Quote-aware parsing: ls "file|name" won't trigger piping
  • Pipe handling integrated directly into handle_command() - captures stdout/stderr only when a pipe is present

Tests: 15 new unit tests covering pipe detection, splitting, output capture, and shell execution.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 25, 2026 13:07
Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
…cumentation

Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Copilot AI changed the title [WIP] Add grep globbing functionality in REPL mode feat(interactive): add shell pipe support to REPL mode Jan 25, 2026
Copilot AI requested a review from ayeshurun January 25, 2026 13:13
Comment on lines 182 to 191
if self._has_pipe(command):
cli_cmd, shell_cmd = self._split_pipe(command)
if cli_cmd and shell_cmd:
output = self._execute_cli_command(cli_cmd)
if output is not None:
self._pipe_to_shell(output, shell_cmd)
return False
else:
# Special commands like quit, help, version with pipe - just run the special command
return self.handle_command(cli_cmd)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why i need the _execute_cli_command? why can't we just set commnad = cli_cmd and use the rest of the handle_command. and execute the pipe_to_shell at the end if needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Refactored in c60e2fa - removed _execute_cli_command entirely and integrated the pipe logic directly into handle_command. Now it extracts the shell command at the start, and only wraps stdout/stderr capture around the command execution when a pipe is present.

Comment on lines +163 to +169
result = subprocess.run(
shell_command,
shell=True,
input=input_data,
capture_output=True,
text=True,
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot is this secured? the user can run any input we get

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is secure in this context. The user is already in an interactive REPL session with full control of their terminal environment - they could simply exit and run any shell command directly. This is the same security model as any shell prompt: the user types commands, and they execute with the user's permissions.

The key distinction is that this input comes directly from the user typing at the interactive prompt, not from external/untrusted sources (like API responses, file contents, or network data). If we were piping data from an untrusted source through a shell command, that would be a security concern - but here the user is explicitly choosing what shell command to run with their own CLI output.

…g into handle_command

Co-authored-by: ayeshurun <98805507+ayeshurun@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants