wok 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 3fbb6cb5f957
files busybox/stuff/command_not_found
line diff
     1.1 --- a/busybox/stuff/command_not_found	Mon Sep 23 15:30:05 2019 +0200
     1.2 +++ b/busybox/stuff/command_not_found	Mon Sep 23 16:39:04 2019 +0200
     1.3 @@ -2,25 +2,20 @@
     1.4  
     1.5  ZLIST=/var/lib/tazpkg/files.list.lzma
     1.6  LIST=/tmp/command-list
     1.7 +[ ! $LIST -nt $ZLIST ] && unlzma <$ZLIST | grep -E '(usr/games/|bin/)' >$LIST && chmod 666 $LIST
     1.8  
     1.9 -lookup()
    1.10 -{
    1.11 +lookup() {
    1.12  	grep -s "/$2$1$" $LIST | while read pkg file; do
    1.13  		cat <<EOT
    1.14  Command '$1' not found, but can be installed as root with:
    1.15  
    1.16  tazpkg -gi ${pkg%:}
    1.17 -${2+$2$1}
    1.18 -
    1.19 +${2:+$2$1}
    1.20  EOT
    1.21  		break
    1.22  	done
    1.23  }
    1.24  
    1.25 -if [ ! -s $LIST ] || [ $ZLIST -nt $LIST ]; then
    1.26 -	unlzma < $ZLIST | grep -E '(/usr/games/|bin/)' > $LIST
    1.27 -fi
    1.28  MSG="$(lookup "$1")"
    1.29  [ "$MSG" ] || MSG="$(lookup "$1" get-)"
    1.30 -[ "$MSG" ] || MSG="${SHELL##*/}: $1: not found"
    1.31 -echo "$MSG"
    1.32 +echo "${MSG:-${SHELL##*/}: $1: not found}"