I have added a script to /usr/local/bin/apt-get on an Ubuntu Trusty system which does some checking that is required before launching the "official" apt-get.
For reasons I simply cannot comprehend this script is completely ignored despite everything telling me that it shouldn't be.
For testing purposes the script currently does nothing and should simply exit, but it is never launched anyway.
/usr/local/bin has priority in the $PATH:
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ which apt-get
/usr/local/bin/apt-get
$ ls -l /usr/local/bin/apt-get
-rwxr-xr-x 1 root root 553 Apr 16 03:01 /usr/local/bin/apt-get
strace appears to execute the script:
$ strace apt-get
execve("/usr/local/bin/apt-get", ["apt-get"], [/* 26 vars */]) = 0
[...]
open("/usr/local/bin/apt-get", O_RDONLY) = 3
[...]
read(10, "#!/bin/sh\n\n# Note: this little s"..., 8192) = 553
Yet the script is clearly being ignored:
$ apt-get
apt 1.0.1ubuntu2 for amd64 compiled on Oct 28 2014 20:55:14
Usage: apt-get [options] command
...
Launching /usr/local/bin/apt-get directly exits silently, as it should, so the script itself is executable and works correctly.
Could this be a hidden security setting that I know nothing about?