文档

内置工具›Shell

Bash

bash
分组
Shell
开启方式
对话设置「工具」页里它自己的开关。
审批
需审查:写入和无边界的操作要你批准,除非安全级别或之前的「总是允许」已经覆盖。
档案键
tool.bash.description

在对话工作区里用 Bash 运行一行命令,并返回它的输出。

在 macOS 和 Linux 上,用的是 PATH 里找到的第一个 bash;在 Windows 上用的是 Git Bash,要跑 Linux 命令请用 WSL 里的工作区。在本机上,每次调用都会载入你的 ~/.bashrc 里的别名、函数和 PATH。

什么时候询问你

从不提供总是允许。确认卡显示完整命令;要在后台运行的命令标有 [后台]。递归删除的目标是文件系统根目录、你的主目录、/etc 这类系统目录,或者是由变量或命令替换拼出的路径时,在任何层级下都会询问,完全访问也不例外。

值得知道

  • 到了超时还没结束的命令会转到后台继续运行,不论是主代理、子代理还是工作流步骤运行的,即使已经有 8 个后台任务在运行。子代理或工作流步骤的后台命令向它汇报,它给出最终回复时还在运行的会被停止。Mework 退出或崩溃时,后台命令随之结束。
  • 每个工作区,无论在哪台机器上,都记住上一条成功的命令结束时所在的目录,这个工作区的下一条命令就从那里开始。命令结束时如果已在工作区外,下一条回到工作区根目录开始,这条命令的结果里会说明。后台命令从记住的目录开始,但不会改变它。

参数

参数类型说明
command 必填
命令
stringThe Bash command line.
description
说明
stringOne short sentence, in active voice, saying what this command does. Name the action itself; do not hedge with words such as "complex" or "risky". For ordinary commands (git, npm, everyday CLI tools) keep it to five to ten words: - ls → "List files in current directory" - git status → "Show working tree status" - npm install → "Install project dependencies" For commands that are hard to read at a glance (pipelines, unusual flags, find/xargs) add just enough context to make the effect clear: - find . -name "*.tmp" -exec rm {} ; → "Delete every .tmp file under the current directory" - git reset --hard origin/main → "Discard local changes and match remote main" - curl -s url | jq '.data[]' → "Fetch JSON from a URL and print its data entries"
run_in_background
后台运行
booleanRun the command as a background task instead of blocking this call. The receipt carries its shell:<id> address.
timeout
超时(毫秒)
numberOptional timeout in milliseconds (default 120000, max 600000). On expiry the command is moved to the background rather than stopped, and the receipt carries its shell:<id> address.

在 GitHub 上编辑本页