diff -Nur --no-dereference e-smith-lib-compspec-2.6.0.old/root/etc/profile.d/e-smith-lib_compspec.sh e-smith-lib-compspec-2.6.0/root/etc/profile.d/e-smith-lib_compspec.sh --- e-smith-lib-compspec-2.6.0.old/root/etc/profile.d/e-smith-lib_compspec.sh 2022-04-06 16:16:21.057000000 -0400 +++ e-smith-lib-compspec-2.6.0/root/etc/profile.d/e-smith-lib_compspec.sh 2022-04-06 16:18:35.104000000 -0400 @@ -20,7 +20,7 @@ _esmith_expand-template () { if [ ! $(which $1 2>/dev/null) ]; then return 0; fi - local cur; cur=${COMP_WORDS[$COMP_CWORD]} + local cur; cur=$(echo ${COMP_WORDS[$COMP_CWORD]}| sed 's/\./\\./g') case $COMP_CWORD in 1) # need to distinguish between templates and fragments COMPREPLY=( $(find /etc/e-smith/templates \ @@ -43,6 +43,8 @@ if [ ! $(which $1 2>/dev/null) ]; then return 0; fi local cur; cur=${COMP_WORDS[$COMP_CWORD]} + local Commands=$(/sbin/e-smith/db 2>&1 | grep "dbfile" | awk '{print $3}') + case $COMP_CWORD in 1) # config file COMPREPLY=( $(find /home/e-smith /home/e-smith/db -maxdepth 1 -type f \ @@ -50,13 +52,19 @@ -name "$cur*" -printf "%f\n" \)) ) ;; 2) # subcommand - COMPREPLY=( $(/sbin/e-smith/db 2>&1 |awk '{print $3}' \ + COMPREPLY=( $(/sbin/e-smith/db 2>&1 | grep "dbfile"|awk '{print $3}' \ |grep "^$cur" ) ) ;; 3) # key local file; file=${COMP_WORDS[1]} local cmd; cmd=${COMP_WORDS[2]} local haskey + + echo "$Commands" | grep -q "^$cmd" + if [ $? -eq 1 ] ; then + COMPREPLY+=("Unknown command '$cmd'" ""); return 0 + fi + haskey=$(/sbin/e-smith/db 2>&1 | grep "dbfile $cmd" | awk '{print $4}') if [ -n "$haskey" ]; then COMPREPLY=( $(/sbin/e-smith/db $file keys |grep "^$cur") ) @@ -69,6 +77,12 @@ local i; i=$COMP_CWORD local prev local valtype + + echo "$Commands" | grep -q "^$cmd" + if [ $? -eq 1 ] ; then + COMPREPLY+=("Unknown command '$cmd'" ""); return 0 + fi + while [ "$valtype" == "..." ] || [ "$valtype" == "" ]; do prev=${COMP_WORDS[$[i-1]]} PAT='$3'