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