[1173] in athena10
Re: [Debathena] #116: Hook whichlocker into command-not-found
daemon@ATHENA.MIT.EDU (Debathena Trac)
Thu Feb 19 13:53:57 2009
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
From: "Debathena Trac" <debathena@MIT.EDU>
Cc: debathena@mit.edu
To: broder@mit.edu, jdreed@mit.edu
Date: Thu, 19 Feb 2009 18:53:48 -0000
Reply-To:
Message-ID: <052.eabbab27d3915b1c482beca52d5386d8@mit.edu>
In-Reply-To: <043.8b21630aa046b9f3efeeb4d1874a80d7@mit.edu>
Content-Transfer-Encoding: 8bit
#116: Hook whichlocker into command-not-found------------------------+---------------------------------------------------
Reporter: broder | Owner:
Type: enhancement | Status: new
Priority: minor | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment(by jdreed):
I looked a the source, things like "packages" and "apt-get install" are
hardcoded. We could hack it, of course, but I wonder how maintainable
that would be. It seems like it would be simpler to just change the
command_not_found bash hook, and have it run whichlocker first, and then
run /usr/lib/command-not-found. We already divert /etc/bash.bashrc, so
we'd just need to add our own hook after we source Ubuntu's stock bashrc.
Something like this should work:
{{{
function command_not_found_handle {
if [ -x /mit/outland/arch/@sys/bin/whichlocker ]; then
WARNED=1 /mit/outland/arch/@sys/bin/whichlocker $1
fi
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- $1
return $?
else
return 127
fi
}
}}}
We probably want to tweak it. I initially have WARNED=1 because the
warning that whichlocker generates can get annoying after a while. We
probably want to display our own text.
I wonder if the right thing to do is patch whichlocker to take a command
line option to display the information in a format we want. Then we can
do something like:
{{{
function command_not_found_handle {
if [ -x /mit/outland/arch/@sys/bin/whichlocker ]; then
INLOCKER=`WARNED=1 /mit/outland/arch/@sys/bin/whichlocker $1`
if [ ! -z "$INLOCKER" ]; then
echo "Found in the following Athena lockers:"
echo $INLOCKER
fi
fi
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- $1
return $?
else
return 127
fi
}
}}}
I want the output to be informative but minimal if a program is both in an
Athena locker and in the apt repository (eg, drscheme)
Relatedly, it would probably be a good idea to generate a command-not-
found database for the debathena repository.
-- Ticket URL: <http://debathena.mit.edu/trac/ticket/116#comment:1>Debathena <http://debathena.mit.edu/>MIT Debian-Athena Project