Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/bao_agent/lib/src/util/processes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
5 changes: 5 additions & 0 deletions tool/test_bash_exe.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading