From 49137a757b438dc30fcc2a667b2d63cfb82455d0 Mon Sep 17 00:00:00 2001 From: Dimitar Yanakiev Date: Sun, 2 Mar 2025 11:55:06 +0200 Subject: [PATCH] Fix console working directory for root user (#525) Previously, `$(pwd)` was expanded too early by the parent shell, leading to incorrect working directory output when `cd` was executed within `$request->command`. Replaced `echo "VITO_WORKING_DIR: $(pwd)"` with `echo -n "VITO_WORKING_DIR: " && pwd` to ensure `pwd` executes at the right moment inside the same shell session. Closes #515 --- app/Http/Controllers/ConsoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ConsoleController.php b/app/Http/Controllers/ConsoleController.php index 0774173..9d03700 100644 --- a/app/Http/Controllers/ConsoleController.php +++ b/app/Http/Controllers/ConsoleController.php @@ -37,7 +37,7 @@ public function run(Server $server, Request $request) return response()->stream( function () use ($server, $request, $ssh, $log, $currentDir) { - $command = 'cd '.$currentDir.' && '.$request->command.' && echo "VITO_WORKING_DIR: $(pwd)"'; + $command = 'cd '.$currentDir.' && '.$request->command.' && echo -n "VITO_WORKING_DIR: " && pwd'; $output = ''; $ssh->exec(command: $command, log: $log, stream: true, streamCallback: function ($out) use (&$output) { echo preg_replace('/^VITO_WORKING_DIR:.*(\r?\n)?/m', '', $out);