mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 01:51:14 -03:00
These binaries are not guaranteed to exist at /bin/X on all systems, e.g. nixos does not place binaries there, but as long as they are in the PATH we can find them with command. Part of #12544
45 lines
699 B
Fish
45 lines
699 B
Fish
# RUN: fish=%fish %fish %s
|
|
|
|
set -g nproc (
|
|
if command -v nproc >/dev/null
|
|
nproc
|
|
else
|
|
sysctl -n hw.logicalcpu
|
|
end
|
|
)
|
|
function run-concurrently
|
|
for i in (seq (math "10 * min($nproc, 16)"))
|
|
$fish -c $argv[1] &
|
|
end
|
|
wait
|
|
end
|
|
|
|
run-concurrently '
|
|
set t "$(
|
|
command echo -n A
|
|
echo -n B
|
|
)"
|
|
test $t = AB
|
|
or echo $t
|
|
'
|
|
|
|
run-concurrently '
|
|
eval "
|
|
command echo -n C
|
|
echo -n D
|
|
" | read -l t
|
|
test $t = CD
|
|
or echo $t
|
|
'
|
|
|
|
run-concurrently '
|
|
# block/function node output is buffered also
|
|
begin
|
|
command echo -n E
|
|
echo -n F
|
|
end |
|
|
read -l t
|
|
test $t = EF
|
|
or echo $t
|
|
'
|