{"id":5545,"date":"2004-11-30T19:36:06","date_gmt":"2004-12-01T03:36:06","guid":{"rendered":"http:\/\/www.ikillspies.com\/blog\/2004\/11\/30\/5545\/"},"modified":"2004-11-30T19:36:06","modified_gmt":"2004-12-01T03:36:06","slug":"magic-which","status":"publish","type":"post","link":"http:\/\/www.ikillspies.com\/?p=5545","title":{"rendered":"Magic &#8220;which&#8221;"},"content":{"rendered":"<p>I&#8217;m using <b>.bash<\/b>.  For whatever reason, it doesn&#8217;t detect aliases!<\/p>\n<p \/>\n<p>This bit me on the ass recently:  a party who shall remain nameless had the default <b>grep<\/b> aliased:<\/p>\n<pre>alias grep='grep -i'<\/pre>\n<p>Yuck.<\/p>\n<p \/>\nSo when I searched for some debugging info, I got thousands of lines of false positives.  Very bad.<\/p>\n<p \/>\n<p>But when I did a &#8220;<b>which grep<\/b>&#8221; it just told be the location of the executable.  Not that it was aliased.  So it looked like my <b>grep<\/b> (bash on debian) was broken!<\/p>\n<p \/>\n<p>What I wanted for <b>which<\/b> is:<\/p>\n<ul>\n<li>if there is an alias, display the alias<\/li>\n<li>if not, display the path of the executable<\/li>\n<\/ul>\n<p>So the magic command to make <b>which<\/b> behave like it should is:<\/p>\n<pre>alias which='alias | \/usr\/bin\/which --read-alias'<\/pre>\n<p \/>\nJust kidding.  What that does is &#8220;crash your bash.&#8221;  Who knows why.  Crebbs told me that&#8217;s what it was (so much for nameless) and I almost locked myself out of my computer.<\/p>\n<p \/>\nTurns out the &#8220;magic&#8221; command is simply<\/p>\n<pre>type<\/pre>\n<p>which is built in to bash.  Gah!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using .bash. For whatever reason, it doesn&#8217;t detect aliases! This bit me on the ass recently: a party who shall remain nameless had the default grep aliased: alias grep=&#8217;grep -i&#8217; Yuck. So when I searched for some debugging info, I got thousands of lines of false positives. Very bad. But when I did a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-5545","post","type-post","status-publish","format-standard","hentry","category-looky"],"_links":{"self":[{"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=\/wp\/v2\/posts\/5545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5545"}],"version-history":[{"count":0,"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=\/wp\/v2\/posts\/5545\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5545"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ikillspies.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}