Fix cd parsing for compound commands

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mirivlad 2026-02-23 16:15:46 +08:00
parent 8070762310
commit 5472ea4048
1 changed files with 4 additions and 2 deletions

6
bot.py
View File

@ -654,8 +654,10 @@ async def execute_cli_command_from_message(update: Update, command: str):
working_dir = state.working_directory or config.get("working_directory", str(Path.home())) working_dir = state.working_directory or config.get("working_directory", str(Path.home()))
# Обработка команды cd - меняем директорию пользователя # Обработка команды cd - меняем директорию пользователя
if command.strip().startswith("cd "): # Работает только с простыми командами cd, не с составными
parts = command.strip().split(maxsplit=1) cmd_stripped = command.strip()
if cmd_stripped.startswith("cd ") and "&&" not in cmd_stripped and ";" not in cmd_stripped and "|" not in cmd_stripped:
parts = cmd_stripped.split(maxsplit=1)
if len(parts) == 2: if len(parts) == 2:
target_dir = parts[1] target_dir = parts[1]