I&#x27;m afraid I&#x27;m just not clear as to why Xcode needs those shims. Those shims are designed to launch a dialog box prompting to install the command line tools. They are completely unnecessary, because as it turns out bash does this better, but for that you need v4.<p>The fact that there is a dialog box that comes up means that if a script is run then it should fail if it can&#x27;t find git. Preinstalled shim executables are a bad idea - I would hope that bash <i>not</i> find git rather than automatically ask to install the XCode Command Line Tools!<p><i>&gt;&gt; Who switches the PATH to &#x2F;usr&#x2F;bin:&#x2F;bin or &#x2F;usr&#x2F;local&#x2F;bin:&#x2F;usr&#x2F;bin:&#x2F;bin?</i><p><i>&gt; Someone who&#x27;s writing a script and wants to be insulated from potentially-malicious entries in PATH. Or shells or shell-like programs executed without any PATH provided at all, which can happen if you invoke them with `env -i`.</i><p>Then they should point PATH to the standard locations where the software is installed, which would indicate that if there was a further directory then they should append it to the end. Not entirely sure what the issue is with this.<p>Somewhat ironically, if they are expecting that git would be the one run in the &#x2F;usr&#x2F;bin directory they would find that the shim bypassed the PATH variable entirely and executed a binary in an entirely different directory. So much for their concern over insulating from potentially-malicious entries by reducing the search path to &#x2F;usr&#x2F;local&#x2F;bin and &#x2F;usr&#x2F;bin...<p><i>&gt;&gt; Perhaps because of the same reason why on the average server it&#x27;s suggested that to keep your attack surface as low as possible you only install the minimum set of utilities and services necessary for the server to be operational?</i><p><i>&gt; Huh? What does any of this have to do with attack surface? These tools are on the system regardless, moving them into a different directory has no bearing on attack surface.</i><p>I never said that. You cannot remove the shims, so in essence you haven&#x27;t removed the software. If you are forced into keep the shims, even though you don&#x27;t want to have git installed, you still potentially have it installed. The shims themselves have the most opaque way of finding git I can possibly think of... the following is what I found on it:<p>&quot;Below are what I&#x27;ve deduced its order of checks to be. Remember that this checking is the responsibility of libxcselect. xcode-select simply provides a way of manipulating some configuration on the system that libxcselect will make use of when one of these shim commands is run, or if xcrun is invoked directly by the user with specific options.<p>If the DEVELOPER_DIR environment variable is set when a command is run, any system default will be overridden.<p>If a symlink at &#x2F;var&#x2F;db&#x2F;xcode_select_link is present and it points to a valid developer dir within an Xcode or the CLI tools, this will be used. This symlink will be created when running xcode-select -s &lt;path&gt; if &lt;path&gt; is either an alternate Xcode path or that of the CLI tools, and there is already an Xcode.app in &#x2F;Applications.<p>If neither of the above are set, and the path &#x2F;Applications&#x2F;Xcode.app&#x2F;Contents&#x2F;Developer is present, this is used.
If no Xcode path as above are set, but CLI tools are installed in &#x2F;Library&#x2F;Developer&#x2F;CommandLineTools, these are selected.&quot; [1]<p>Note that those are from shims preinstalled on OS X.<p>So basically, the shim runs xcrun, which relies on xcode-select. xcode-select allows you to set the environment variable 
DEVELOPER_DIR to whereever you want, and will switch to this directory then run the tool from within there. That&#x27;s a remarkably convoluted process, and frankly I can see how easy it would be to increase attack surface.<p>The issue I have with the shims is that there is no way of removing them by default.<p><i>&gt;&gt; and if a non-system binary is replaced and that binary is installed in a location away from system binaries you can put it back?</i><p><i>&gt;..what? I genuinely can&#x27;t figure out what you&#x27;re trying to say with this sentence.</i><p>I did explain myself poorly there. All I&#x27;m saying is that any non-critical software can be installed into a different directory. Currently it is installed in a system directory where the entire point of it being immutable is to ensure that no binaries can be modified by anyone other than the installer service, yet those shims bypass this by ensuring that if you run the shim, you actually are running an entirely different executable located on a part of the system where malware <i>does</i> have write access. Thus defeating the purpose of SIP!<p><i>&gt;&gt; Not to mention that only under the current situation only Apple can supply security updates to a third party took they don&#x27;t actually maintain?</i><p><i>&gt; Congratulations, you&#x27;ve just described how every third-party component bundled with the system works.</i><p>Indeed - and I&#x27;m saying it&#x27;s a bad situation if the software has gaping security holes that don&#x27;t get patched quickly or effectively by Apple - and you can&#x27;t remove it easily.<p><i>&gt; &gt; And they can&#x27;t be as quick as a system administrator who wants to remove it entirely?</i><p><i>&gt; That&#x27;s completely nonsense. Any &quot;system administrator&quot; that believes these tools should be removed from OS X should be fired for incompetence. These are shims, and their entire point is to provide a predictable location within the default PATH for a bunch of tools that are actually bundled inside Xcode or the standalone Command Line Tools download. If you don&#x27;t want to have git&#x2F;clang&#x2F;etc on your system, don&#x27;t install Xcode or the standalone Command Line Tools. It&#x27;s that simple.</i><p>What? If you want to install OS X command line tools, then use:<p>xcode-select --install<p>What doesn&#x27;t make any sense is to have a &quot;shim&quot; that invokes a dialog box when you invoke the command to install the XCode command line tools. What you currently have is a situation where if someone has an environment where they might be invoking git in a script then it runs a program that invokes an interactive dialog box prompting to install the XCode command line tools! Aside from the sheer silliness of a dialog box in a shell script, there are a lot of shell scripts that expect that if the system can&#x27;t find the binary, then the shell will invoke an error which they catch and handle gracefully.<p><i>&gt; So really this pretty much boils down to &quot;if you don&#x27;t want developer tools on your system, don&#x27;t install the developer tools&quot;. All that you&#x27;ll have are a set of shims that offer to install the developer tools if you try and run them (which I hope you can see is a pretty sensible suggestion, and is akin to how linux distros often suggest packages you can install when you try and execute commands that don&#x27;t exist).</i><p>No, what it boils down to is that if you have a tool that you don&#x27;t want installed on the system you get a shim binary that executes regardless and makes it harder to handle in your average shell script.<p>What you don&#x27;t realise when you speak about how Linux distros suggest packages is that they don&#x27;t actually run a new executable, they are actually using a version of bash equal to or higher than version 4, which looks for the shell function command_not_found_handle. This gives a number of suggestions and returns status code 127, which is the same code that you get if the shell can&#x27;t find the executable or that function. [2] There is absolutely no executing of a specific binary, it&#x27;s all completely done within the user&#x27;s bash environment.<p>Apple currently use bash 3.2.57(1) on my OS X El Capitan system, so they don&#x27;t have the ability to leverage this feature. Which is a shame as it is far and away more sensible that preemptively installing a shim in the directory where the binary would normally be. Which, as far as I can tell, was an inelegant hack done by the XCode install team all the way back in OS X Maverick and preloaded on OS X. It&#x27;s not scalable in any way, as it relies on the Operating System to know about all possible software that might or might not be installed by the user - having shims for each and every possible 3rd-party program in existence is hardly a good strategy - and not one that Linux distributions follow.<p>1. <a href="https:&#x2F;&#x2F;macops.ca&#x2F;developer-binaries-on-os-x-xcode-select-and-xcrun" rel="nofollow">https:&#x2F;&#x2F;macops.ca&#x2F;developer-binaries-on-os-x-xcode-select-an...</a><p>2. <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;bash&#x2F;manual&#x2F;bashref.html#Command-Search-and-Execution" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;bash&#x2F;manual&#x2F;bashref.html#Comman...</a>