which package icon
icedcoffee/which
Public
wasmer run icedcoffee/which

which — locate a command in PATH, for WASIX

GNU which 2.21 (Debian trixie's version), built for WASIX.

wasmer run icedcoffee/which -- sh
wasmer run icedcoffee/which -- --all python python3
wasmer run icedcoffee/which -- --read-alias --read-functions ls

What is in the package

which with -a/--all, -i/--read-alias, --read-functions, --skip-dot, --skip-tilde, --show-dot, --show-tilde, --tty-only, and the usual -s/-v. It is the bash-compatible variant (reads aliases and functions when asked), which is what Debian ships.

One patch

which decides executability from the mode bits: as root it wants st_mode & S_IXUGO, otherwise S_IXUSR/S_IXGRP/S_IXOTH. WASIX keeps no permission bits — st_mode is 0 for a regular file — so every lookup answered "not found", including /bin/sh.

bash.c now treats a regular file with no mode bits at all as executable and readable, and leaves the decision to the runtime, which is where it actually lives.

Verified

$ which sh
/bin/sh
$ which --all python python3
/bin/python
/bin/python3
$ which nosuch
$ echo $?
1

Building

./configure --host=wasm32-wasi
make

with the standard WASIX flag set: -matomics -mbulk-memory -pthread -mthread-model posix -ftls-model=local-exec, -Wl,--shared-memory -Wl,--import-memory -Wl,--max-memory=4294967296 and the __heap_base/__stack_pointer/__wasm_init_tls/__tls_* exports. 85 KiB, no asyncify.

License: GPL-3.0-or-later, as upstream.

GNU which for WASIX - locate a command in PATH


Github