wok-current view busybox/stuff/command_not_found @ rev 21861

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