Comment 48 for bug 1055766

Revision history for this message
Stuart Prescott (themill) wrote :

It would be shortsighted to do this only for grep.

A better approach would be to set PROMPT_COMMAND for the shell in /etc/bash.bashrc to an appropriate shell function. The last command executed is available as `history 1` in that handler:

--- bash.bashrc.orig 2012-09-27 16:52:30.452001532 +0100
+++ bash.bashrc 2012-09-27 16:54:24.312515801 +0100
@@ -53,3 +53,6 @@
                fi
        }
 fi
+
+PROMPT_COMMAND='/usr/lib/ubuntu-amazon/prompthandler "$(history 1)"'
+

The handler can then work out what sort of output the user really wanted to see in their shell based on the command given and also the arguments. Commands like "nslookup", "dig" and "hosts" could offer registration deals from GoDaddy. Commands like "passwd" could offer to sell the user books on managing security policies. Commands like "vlc", "mplayer" could could sell videos and music.

Communicating the command and arguments to an external server would presumably be necessary, but I can't imagine anyone objecting to that.