मेरे पास यह टुकड़ा है /etc/bash.bashrc(Ubuntu 14.04.4 LTS):
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
ऐसा लगता है कि आपको command_not_found_handleफ़ंक्शन को अधिलेखित करना चाहिए । मुझे नहीं पता कि इसके लिए पैकेज command-not-foundकी आवश्यकता है या नहीं; मुझे लगता है कि नहीं, लेकिन मैं गलत हो सकता है।
उदाहरण:
function command_not_found_handle { echo BOOM! ; }
नतीजा:
$ foo12345
BOOM!
$ echo "echo is valid command"
echo is valid command
$ agrgokdnlkdgnoajgldfnsdalf grhofhadljh
BOOM!
$ cat /etc/issue
Ubuntu 14.04.4 LTS \n \l
$ catt /etc/issue
BOOM!
वापस करने के लिए (जल्दी और गंदे):
# Assuming you haven't modified /etc/bash.bashrc
. /etc/bash.bashrc
# Quick and dirty, because if your ~/.bashrc or ~/.bash_profile //
# overwrites some settings from /etc/bash.bashrc //
# you need to source them again.
# Things may get complicated, I won't cover all the ifs here.
# Logout and login again for the clean start.
/etc/bash.bashrcसभी उपयोगकर्ताओं के लिए "कमांड नहीं मिला" व्यवहार को बदलने के लिए संशोधित करें । केवल अपने लिए काम करने के लिए अपने command_not_found_handleको परिभाषित करें ~/.bashrc। या अपने हैक को सक्षम और अक्षम करने के लिए उचित फ़ंक्शन परिभाषाओं के साथ दो फाइलें लिखें। महत्वपूर्ण: फ़ाइलों को निष्पादित न करें, उन्हें इस तरह से स्रोत करें:
. ~/.hack_enable
. ~/.hack_disable
जहां .hack_enableआपके कार्य को परिभाषित किया .hack_disableगया है, मूल एक पर जाता है (मेरे उत्तर के पहले कोडब्लॉक से या आपके मामले में ऐसा ही कुछ सही है)।
scriptकरता है, तोcommandविफल रहता है, का उपयोग करें:command || script।