MCPcopy
hub / github.com/vercel-labs/just-bash / executeCommand

Method executeCommand

packages/just-bash/src/cli/shell.ts:114–152  ·  view source on GitHub ↗
(command: string)

Source from the content-addressed store, hash-verified

112 }
113
114 private async executeCommand(command: string): Promise<void> {
115 const trimmed = command.trim();
116
117 // Skip empty commands
118 if (!trimmed) {
119 return;
120 }
121
122 // Add to history
123 this.history.push(trimmed);
124
125 // Handle shell built-ins that need special treatment
126 if (trimmed === "exit" || trimmed.startsWith("exit ")) {
127 const parts = trimmed.split(/\s+/);
128 const exitCode = parts[1] ? parseInt(parts[1], 10) : 0;
129 console.log("exit");
130 process.exit(exitCode);
131 }
132
133 // Sync local history with Bash's history for the history command
134 this.syncHistory();
135
136 // Execute command in Bash
137 try {
138 const result = await this.env.exec(trimmed);
139
140 if (result.stdout) {
141 process.stdout.write(result.stdout);
142 }
143
144 if (result.stderr) {
145 process.stderr.write(`${colors.red}${result.stderr}${colors.reset}`);
146 }
147 } catch (error) {
148 console.error(
149 `${colors.red}Error: ${getErrorMessage(error)}${colors.reset}`,
150 );
151 }
152 }
153
154 private printWelcome(): void {
155 console.log(`

Callers 3

promptMethod · 0.95
runMethod · 0.95
TerminalComponentFunction · 0.45

Calls 7

syncHistoryMethod · 0.95
getErrorMessageFunction · 0.85
exitMethod · 0.80
writeMethod · 0.80
errorMethod · 0.80
splitMethod · 0.65
execMethod · 0.65

Tested by

no test coverage detected