From 9fd3c716897797c5aeb982d7d2f41f1f054e99fb Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 16 Nov 2026 22:23:26 +0800 Subject: [PATCH] BaoCode Bash 0.3.0: tell agents how to write paths; test the new cases The bash note now says paths print as C:/x and to write them that way (bash and Windows programs both read it), that C:\x and /c/x name the same file, that cygpath converts and PATH="$PATH:/c/tools" adds a folder. test_bash_exe.ps1 checks C:/x output, cygpath, a ":"-appended PATH entry, $PPID, and exec bash / exec env with a #!/usr/bin/env bash script. Co-Authored-By: BaoCode --- packages/bao_agent/lib/src/util/processes.dart | 9 ++++++--- tool/test_bash_exe.ps1 | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/bao_agent/lib/src/util/processes.dart b/packages/bao_agent/lib/src/util/processes.dart index b551002be..a3df92495 100644 --- a/packages/bao_agent/lib/src/util/processes.dart +++ b/packages/bao_agent/lib/src/util/processes.dart @@ -163,9 +163,12 @@ class Shell { 'The shell is bash (BaoCode Bash), with the usual Unix tools built in: ' '`rg`, `grep`, `sed`, `awk`, `find`, `xargs`, `jq`, `tar`, `diff`, ' '`timeout`, `sha256sum`, the coreutils and more (`type -t NAME` says ' - '`builtin` for one). Write paths as `C:\\x`, `C:/x` or `/c/x`: all name ' - 'the same file, and `/tmp` is the temporary folder. Windows programs on ' - 'the PATH run as usual and write UTF-8.'; + '`builtin` for one). Paths print as `C:/x` (`pwd`, `\$PWD`, `\$HOME`, ' + '`realpath`); write them that way too, as bash and Windows programs ' + 'both read it. `C:\\x` and `/c/x` name the same file, `/tmp` is the ' + 'temporary folder, `cygpath -w`/`-u` converts, and ' + '`PATH="\$PATH:/c/tools"` adds a folder. Windows programs on the PATH ' + 'run as usual and write UTF-8.'; /// What a model is told of PowerShell, where it would write bash. static const powershellNote = diff --git a/tool/test_bash_exe.ps1 b/tool/test_bash_exe.ps1 index 598a20c2b..bd12f23bb 100644 --- a/tool/test_bash_exe.ps1 +++ b/tool/test_bash_exe.ps1 @@ -148,6 +148,11 @@ try { Test-Bash '/bin and /usr/bin paths' '/bin/bash -c "echo ok"; /usr/bin/env A=1 node -e "console.log(process.env.A)"; /bin/sh -c "type -t rg"' '^ok\n1\nbuiltin\n$' Test-Bash 'env -i' 'env -i bash -c "echo clean:\$A"; env -i node -e "console.log(1)"' '^clean:\n1\n$' Test-Bash 'pwd -W and rev' 'cd /c/Windows && pwd -W; echo abc | rev' '(?i)^c:/windows\ncba\n$' + Test-Bash 'paths print as C:/x' 'cd /c/Windows && echo "$PWD/x"; pwd -P; realpath .; cd /tmp && [[ $PWD == ?:/* && $PWD != *\\* ]] && echo tmp; [[ $HOME == ?:/* ]] && echo home' '(?i)^c:/windows/x\nc:/windows\nc:/windows\ntmp\nhome\n$' + Test-Bash 'cygpath' 'cygpath -u "C:\Windows"; cygpath -w /c/Windows; cygpath -m /c/x; cygpath -wp /c/a:/d/b' '(?i)^/c/Windows\nC:\\Windows\nC:/x\nC:\\a;D:\\b\n$' + Test-Bash 'PATH="$PATH:/dir"' 'mkdir -p bin && printf "#!/bin/sh\necho appended\n" > bin/tool && PATH="$PATH:$(cygpath -u "$PWD")/bin" && tool && cmd //c "echo %PATH%" | tr ";" "\n" | tail -1' '(?i)^appended\n[a-z]:/.*/bin\r?\n$' + Test-Bash '$PPID' '[ "$PPID" -gt 0 ] && echo ok' '^ok\n$' + Test-Bash 'exec bash, exec env script' '(exec bash -c "echo in"); printf "#!/usr/bin/env bash\necho ran\n" > e.sh && chmod +x e.sh && (exec env A=1 "$PWD/e.sh")' '^in\nran\n$' # A script run as `bash script.sh` has the tools ahead of PATH, as `-c` # has (System32's `sort`, Git's `xargs` came first).