wok annotate busybox/stuff/command_not_found @ rev 21860
busybox: add command_not_found
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Sep 23 15:30:05 2019 +0200 (2019-09-23) |
parents | |
children | cf17791e53df |
rev | line source |
---|---|
pascal@21860 | 1 #!/bin/sh |
pascal@21860 | 2 |
pascal@21860 | 3 ZLIST=/var/lib/tazpkg/files.list.lzma |
pascal@21860 | 4 LIST=/tmp/command-list |
pascal@21860 | 5 |
pascal@21860 | 6 lookup() |
pascal@21860 | 7 { |
pascal@21860 | 8 grep -s "/$2$1$" $LIST | while read pkg file; do |
pascal@21860 | 9 cat <<EOT |
pascal@21860 | 10 Command '$1' not found, but can be installed as root with: |
pascal@21860 | 11 |
pascal@21860 | 12 tazpkg -gi ${pkg%:} |
pascal@21860 | 13 ${2+$2$1} |
pascal@21860 | 14 |
pascal@21860 | 15 EOT |
pascal@21860 | 16 break |
pascal@21860 | 17 done |
pascal@21860 | 18 } |
pascal@21860 | 19 |
pascal@21860 | 20 if [ ! -s $LIST ] || [ $ZLIST -nt $LIST ]; then |
pascal@21860 | 21 unlzma < $ZLIST | grep -E '(/usr/games/|bin/)' > $LIST |
pascal@21860 | 22 fi |
pascal@21860 | 23 MSG="$(lookup "$1")" |
pascal@21860 | 24 [ "$MSG" ] || MSG="$(lookup "$1" get-)" |
pascal@21860 | 25 [ "$MSG" ] || MSG="${SHELL##*/}: $1: not found" |
pascal@21860 | 26 echo "$MSG" |