lackadaisical/what
Sam Hardeman 0912f2d3d4 - Many fixes to sourcing, now will always resolve to base dir.
- All scripts are again `sh` compatible.
- Binbox overhaul, symlinks finally work just like `busybox`.
- Error checking to some files like `sw` and `own`.
TODO: Make it pretty and make `short` already.
2025-09-22 08:34:50 +02:00

32 lines
650 B
Bash
Executable file

#!/bin/sh
# Where is the binary?
# Usage: what [<keyword>]
# Returns:
# With no parameters, all visible binaries in PATH.
# With parameter, all binaries that match the pattern
# given. Accepts default grep patterns, case insensitive
#
# Examples:
# $ what zs.*
# pzstd
# zsh
# zstd
#
# $ what ftp
# ftppass
# sftp
# vsftpd
#
# $ what ftp | xargs which
# /usr/bin/ftppass
# /usr/bin/sftp
# /usr/sbin/vsftpd
#
DAISY_INTERNAL=1
. $(dirname $(realpath $0))/daisy.source
PWD=/
ALL_BINS=$(cd / && echo $PATH | sed 's/[:]/ /g' | xargs ls -A | grep -v ":" | sort | uniq)
OUTPUT=$(printf '%s\n' "-n" $ALL_BINS | grep -i "$1")
echo "$OUTPUT"