wok view busybox/stuff/command_not_found @ rev 21870

busybox/command_not_found: use $PATH (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Sep 25 11:06:27 2019 +0200 (2019-09-25)
parents 3525dfa8c479
children 352e1cee9466
line source
1 #!/bin/sh
3 FILES=/var/lib/tazpkg/files.list.lzma
4 LIST=/tmp/command-list.gz
5 [ ! $LIST -nt $FILES ] && unlzma <$FILES | grep -E "(: ${PATH//:/|: })" | \
6 gzip -9 >$LIST && chmod 666 $LIST
8 lookup() {
9 zcat $LIST | grep "/$2$1$" | while read pkg file; do
10 cat <<EOT
11 Command '$1' not found, but can be installed as root with:
13 tazpkg -gi ${pkg%:}
14 ${2:+$2$1}
15 EOT
16 break
17 done
18 }
20 MSG="$(lookup "$1")"
21 [ "$MSG" ] || MSG="$(lookup "$1" get-)"
22 echo "${MSG:-${SHELL##*/}: $1: not found}"