<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-837664636726682837</atom:id><lastBuildDate>Tue, 11 Aug 2026 17:29:44 +0000</lastBuildDate><category>c++</category><category>negative</category><category>tips</category><category>coding standards</category><category>emacs</category><category>style</category><category>tcl</category><category>shell</category><category>visitor</category><category>gcc</category><category>pattern</category><category>bash</category><category>case analysis</category><category>positive</category><category>csh</category><category>make</category><category>perl</category><category>dead code</category><category>gdb</category><category>jargon</category><category>subversion</category><title>Software EngiSneering</title><description>Unix software development rants.</description><link>http://softwareengisneering.blogspot.com/</link><managingEditor>noreply@blogger.com (Bill Night)</managingEditor><generator>Blogger</generator><openSearch:totalResults>64</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-6214667970634767672</guid><pubDate>Sat, 14 Jun 2014 18:14:00 +0000</pubDate><atom:updated>2014-06-14T11:14:50.079-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Prevent Emacs from Changing Case During Completions</title><description>People where I work have the annoying habit of naming files the same as the class they define, &lt;i&gt;except&lt;/i&gt; that the filename is capitalized differently than the class.&amp;nbsp; So the class ZooAnimal is in files zooAnimal.h and zooAnimal.cpp.&amp;nbsp; Why?&amp;nbsp; &lt;i&gt;Why???&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
It&#39;s annoying enough when I&#39;m trying to locate the file for a given class, but a more frequent annoyance is that when I hit M-/ to run dabbrev-expand, the out-of-the-box behavior is to change the case of what I typed to match the expansion that dabbrev found.&amp;nbsp; Using the example above, if I type &quot;ZooAn M-/&quot;, dabbrev notices #include &quot;zooAnimal.h&quot;, and gives me the completion &quot;zooAnimal&quot;.&amp;nbsp; Grrr...&lt;br /&gt;
&lt;br /&gt;
The dabbrev package is so fundamental that you don&#39;t need to specially enable it in your .emacs file.&amp;nbsp; In fact, I didn&#39;t even realize that&#39;s what I was using, so in my first efforts to change the completion case-folding, I was searching for variables named &quot;*complet*&quot;, and hit a dead end.&amp;nbsp; Only on the next day did I think to C-h k M-/ to find out what function was case-folding the expansions, and that led me immediately to the variable dabbrev-case-fold-search.&amp;nbsp; The default setting for that is the symbol &#39;case-fold-search&#39;, which means to use the same value as case-fold-search.&amp;nbsp; Now, I do find case-folding useful on searches, either for laziness&#39; sake, or because you don&#39;t always remember the exact capitalization of what you&#39;re looking for.&amp;nbsp; So I have case-fold-search set to &#39;t&#39;, meaning the default behavior of dabbrev-expand was very annoying.&lt;br /&gt;
&lt;br /&gt;
Solution:&amp;nbsp; either enter C-h v dabbrev-case-fold-search and click the customize link (and choose &quot;off&quot; for &quot;case is significant&quot; -- both of which are confusing descriptions in my opinion), or in your .emacs put &quot;(setq dabbrev-case-fold-search nil)&quot;.&lt;br /&gt;
&lt;br /&gt;
I purposely left dabbrev out of the post title, hoping people who are confused like me will be more likely to Google it.</description><link>http://softwareengisneering.blogspot.com/2014/06/prevent-emacs-from-changing-case-during.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-5217520383010496535</guid><pubDate>Wed, 10 Apr 2013 18:39:00 +0000</pubDate><atom:updated>2013-04-10T11:39:47.347-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Emacs tip: Use &#39;view-lossage&#39; to answer the question &quot;How did that happen?&quot;</title><description>Does it ever happen that you are thumping along in emacs, and suddenly you are in a mode or buffer that you never knew about before?&amp;nbsp; You must have unintentionally hit some keystroke that caused the change, but what was it?&lt;br /&gt;
&lt;br /&gt;
You can find the answer by typing &lt;code&gt;C-h l&lt;/code&gt; (that&#39;s a little &quot;L&quot;).  This runs &lt;code&gt;view-lossage&lt;/code&gt;, which shows the last 100 characters typed.&lt;br /&gt;
&lt;br /&gt;
For instance, this morning I was suddenly staring at a blank buffer called &quot;ChangeLog&quot;.  What is that thing?  To find out, I typed &lt;code&gt;C-h l&lt;/code&gt;.  A *Help* buffer opened with a few lines of symbols.  Here are the last couple lines: &lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;C-s F I X M E C-a C-n C-n C-n C-n C-n C-n C-n
C-n C-x 2 C-x o C-x V a r C-x u C-h l
&lt;/pre&gt;
&lt;br /&gt;
You start reading the lossage at the end.&amp;nbsp; So, at the end I can see the &lt;code&gt;C-h l&lt;/code&gt; from invoking &lt;code&gt;view-lossage&lt;/code&gt;.&amp;nbsp; Right before that, an undo (&lt;code&gt;C-x u&lt;/code&gt;) to get rid of the typing I had just done into the unknown ChangeLog buffer.&amp;nbsp; Right before that, &lt;code&gt;C-x V a r&lt;/code&gt;.&amp;nbsp; Ah, I meant to &lt;i&gt;search&lt;/i&gt; for &quot;Var&quot;, but I must have hit &lt;code&gt;C-x&lt;/code&gt; instead of &lt;code&gt;C-s&lt;/code&gt;.&amp;nbsp; This is the culprit.&lt;br /&gt;
&lt;br /&gt;
So what do those keys do?&amp;nbsp; It opened a new buffer, but did it have some other harmful side-effect I want to know about?&amp;nbsp; Hit &lt;code&gt;C-h k&lt;/code&gt; to start the &lt;code&gt;describe-key&lt;/code&gt; function, and start typing &lt;code&gt;C-x&lt;/code&gt;, &lt;code&gt;v&lt;/code&gt;, &lt;code&gt;a.&lt;/code&gt;&amp;nbsp; Before I could type the &#39;r&#39;, the *Help* buffer showed up and explained that I had entered the keystroke for &lt;code&gt;vc-update-change-log&lt;/code&gt;, a function that seems like it was more useful back in the days of RCS than today, but which doesn&#39;t harm anything else.&amp;nbsp; Anyway, mystery solved!&lt;br /&gt;
&lt;br /&gt;
There tend to be two situations in which I call &lt;code&gt;view-lossage&lt;/code&gt;.&amp;nbsp; Number one is where I think, &quot;Hmm, I don&#39;t know what I did, but it might be useful.&quot;&amp;nbsp; For that case, view-lossage lets you explore that functionality.&amp;nbsp; That was the case this morning with ChangeLog; I was curious about it but it turned out not to be useful to me.&amp;nbsp; Number two is where I think &quot;I don&#39;t ever want that to happen again&quot;.&amp;nbsp; In that case, figure out the offending keystroke, and then disable it in your .emacs file, like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;(global-unset-key &quot;\C-[\C-[&quot;) ;; prefix-command
(global-unset-key &quot;\C-x\C-p&quot;) ;; mark-page
(global-unset-key &quot;\C-x\C-n&quot;) ;; set-goal-column
&lt;/pre&gt;
&lt;br /&gt;
Those are typos I&#39;ve made before that have annoying effects, so I just completely disable those keystrokes&amp;nbsp; (&lt;code&gt;mark-page&lt;/code&gt; is especially nasty: it sets the mark at the end of the file, and moves the point to the beginning of the file, so there&#39;s not always an easy way to jump back to where you were in the file).&lt;br /&gt;
&lt;br /&gt;</description><link>http://softwareengisneering.blogspot.com/2013/04/emacs-tip-use-view-lossage-to-answer.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-6231408770186533369</guid><pubDate>Sat, 26 Jan 2013 01:17:00 +0000</pubDate><atom:updated>2013-01-25T17:17:32.655-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">coding standards</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>C++ Private Inheritance</title><description>For a long time I believed private inheritance was such an arcane feature that it should be avoided.  In my &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/09/c-coding-standard-introduction.html&quot; target=&quot;_blank&quot;&gt;C++ Coding Standard&lt;/a&gt;, 8.2 stated &quot;Use only public inheritance.&quot;  &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/09/c-coding-standard-inheritance.html&quot; target=&quot;_blank&quot;&gt;Here&lt;/a&gt; was my rationale:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
You might find private or protected inheritance useful to save a few lines of code somewhere. But I claim you should just duplicate the lines of code, rather than couple together classes which are so different conceptually that public inheritance can&#39;t be used. They might be structurally the same today, but if they are conceptually different, that structural similarity may change over time and give you a huge headache.
&lt;/blockquote&gt;
&lt;br /&gt;
I think that rationale is pretty good, but now I&#39;ve decided it might be worthwhile to use private inheritance in some cases.  For instance, it might make sense to inherit from some STL container class, and promote some of its lookup functions or subtypes to &quot;public&quot; with &quot;using&quot; declarations.  Like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;verbatim&gt;  class Foo : private std::map&amp;lt;int, Bar *&amp;gt; {

  public:
    typedef std::map&amp;lt;int, Bar *&amp;gt; Base;
    using Base::key_type;
    using Base::data_type;
    using Base::value_type;
    using Base::const_iterator;
    using Base::begin;
    using Base::end;
    using Base::empty;
    using Base::size;
    using Base::find;&lt;/verbatim&gt;&lt;/pre&gt;
&lt;br /&gt;
The likelihood of the structural change mentioned above is very low in this case, and the &quot;using&quot; declarations -- which I&#39;ll admit I didn&#39;t know could be used that way when I first wrote the standard -- allow you to reuse worthwhile parts of the base class in a very clean and foolproof manner.  Later if you realize there&#39;s another bit of functionality you want to expose publicly, you only have to write a one-liner, not a wrapper function.  Meanwhile, things you might not want exposed -- like operator[]() -- stay out of the interface.&lt;br /&gt;
&lt;br /&gt;
But the clincher for me is that you had better &lt;i&gt;not&lt;/i&gt; inherit publicly from a class like std::map.&amp;nbsp; Why?&amp;nbsp; Because it doesn&#39;t have a virtual destructor.&amp;nbsp; What if someone -- for whatever reason -- ends up with a pointer to a std::map which is actually one of your Foo objects, and wants to delete it?&amp;nbsp; Only the map destructor will be called.&amp;nbsp; If ~Foo() was supposed to delete its values, that won&#39;t happen.&amp;nbsp; Similarly, public inheritance means that someone could take a pointer to a Foo, and then use map&#39;s copy constructor or assignment operator to make a simple pointer copy of the Foo, perhaps unintentionally.&amp;nbsp; Then if the original was deleted, and deleted its values, the copy would hold stale pointers.&lt;br /&gt;
&lt;br /&gt;
Interestingly, I didn&#39;t seem very worried about that situation when I annotated the standard.&amp;nbsp; I &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/09/c-coding-standard-inheritance.html&quot; target=&quot;_blank&quot;&gt;wrote&lt;/a&gt; that you might sometimes break 8.4 -- &quot;Destructors of base classes must be pure virtual (but implemented).&quot; -- giving this &lt;b&gt;bad advice&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
If you have a memory-sensitive class where subclasses will not be used 
polymorphically (or do not require polymorphic destruction), you can 
disregard the rule and get rid of the virtual table pointer.&lt;/blockquote&gt;
&lt;br /&gt;
That seems ridiculous now.&amp;nbsp; That is actually &lt;i&gt;exactly&lt;/i&gt; the use case for private inheritance:&amp;nbsp; you want to reuse some code, but not polymorphically.&lt;br /&gt;
&lt;br /&gt;
This all came to the fore today when I considered making a class &#39;public std::pair&lt;n n=&quot;&quot;&gt;&#39;, so it could model an Edge in a &lt;a href=&quot;http://www.boost.org/doc/libs/1_52_0/libs/graph/doc/table_of_contents.html&quot; target=&quot;_blank&quot;&gt;Boost Graph Library&lt;/a&gt; edge_list&amp;lt;&amp;gt;, which requires &#39;first&#39; and &#39;second&#39; members (at least in the iterator class you instantiate edge_list&amp;lt;&amp;gt; with).&amp;nbsp; But recently a friend of mine had twitted me on another class I wrote that inherits publicly from an STL container, so I started to think about these issues.&lt;/n&gt;&lt;br /&gt;
&lt;br /&gt;
I&#39;m still not sure how I&#39;ll implement my Edge class -- except that it &lt;i&gt;won&#39;t &lt;/i&gt;be public pair -- but I see that I need to change the coding standard someday soon, to reflect the reasonable usage of private inheritance.</description><link>http://softwareengisneering.blogspot.com/2013/01/c-private-inheritance.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-8088611630424548395</guid><pubDate>Wed, 19 Sep 2012 18:12:00 +0000</pubDate><atom:updated>2012-09-19T11:12:00.328-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">coding standards</category><category domain="http://www.blogger.com/atom/ns#">negative</category><category domain="http://www.blogger.com/atom/ns#">style</category><title>Don&#39;t &quot;Namespace&quot; Filenames</title><description>When I first started this blog, I wrote up &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/10/obfuscated-directory-names.html&quot;&gt;a rant&lt;/a&gt; about directory names that mislead about what their contents are.  At the same time, I complained about adding unnecessary morphemes to directory names, things like &quot;db&quot; or &quot;model&quot; or such-like.&lt;br /&gt;
&lt;br /&gt;
I&#39;ve recently become annoyed with the habit of -- for want of a better term -- &quot;namespacing&quot; directory names and file names.  I&#39;m not saying not to use good namespace discipline in source code.  What I mean is having a directory structure like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  zoo/
    zoo_iface/
      zoo_cmds.hpp
      zoo_cmds.cpp
      ...
    zoo_model/
      zoo_cage.hpp
      zoo_animal.hpp
      ...
&lt;/pre&gt;
&lt;br /&gt;
Why does everything have to start with &quot;zoo&quot;?  Look at it this way:  if that was how we named people, then everyone&#39;s last name would be part of their first name and also part of their middle name.  Instead of calling someone Mary Jane Smith, we would know her as MarySmith JaneSmith Smith.  Some people make it even worse by prepending the full directory name onto the file name -- like &quot;zoo_model_cage.hpp&quot;.  Poor Mary Jane would be MaryJaneSmith JaneSmith Smith.&lt;br /&gt;
&lt;br /&gt;
Of course, a source file name may be &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/09/c-coding-standard-source-files.html&quot;&gt;dictated by its contents&lt;/a&gt; -- you&#39;re following our &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/09/c-coding-standard-introduction.html&quot;&gt;C++ standard&lt;/a&gt;, right? -- so my ire is directed at redundant directory names more than filenames.&lt;br /&gt;
&lt;br /&gt;
This principle doesn&#39;t have to stop at source files.&amp;nbsp; It boggles my mind that raw bug testcases where I work start their life with names like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;nbsp; /home/bugs/prod1_bugs/comp2_bugs/bug6003.tgz

&lt;/pre&gt;
&lt;br /&gt;
For crying out loud, I know this is a directory full of bugs, can&#39;t we just call each bug something like:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&amp;nbsp; /home/bugs/prod1/comp2/6003.tgz

&lt;/pre&gt;
&lt;br /&gt;
?
</description><link>http://softwareengisneering.blogspot.com/2012/09/dont-namespace-filenames.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-657512606185559365</guid><pubDate>Tue, 11 Sep 2012 17:02:00 +0000</pubDate><atom:updated>2012-09-11T10:02:10.363-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Disabling Auto-Indent in Emacs</title><description>I have to edit a C++ file at work whose indentation is so screwed up that any punctuation key I type ends up changing the indentation of the line I&#39;m working on to something that is way out of line with the text right around it.  For sanity&#39;s sake I have to &lt;code&gt;M-x&amp;nbsp;set-variable&amp;nbsp;c-syntactic-indentation&amp;nbsp;nil&lt;/code&gt; when I&#39;m working on that file.

The &lt;code&gt;c-syntactic-indentation&lt;/code&gt; variable does not start out buffer-local, meaning that for the sake of the one stupid file, I have turned off the very useful feature of syntactic indentation for every file I have open in that session.  So, if you are ever going to set it temporarily, make sure you have this line in your .emacs file:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  (make-variable-buffer-local &#39;c-syntactic-indentation)&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
While you&#39;re at it, don&#39;t you want a shortcut for the set-variable?  I amused myself greatly this morning as I tried to think what shortcut I would assign this action to.  The obvious mnemonics I polled with &lt;code&gt;C-h&amp;nbsp;k&lt;/code&gt; were taken: I have &lt;code&gt;C-c&amp;nbsp;TAB&lt;/code&gt; set to &lt;code&gt;indent-region&lt;/code&gt;, &lt;code&gt;C-c&amp;nbsp;;&lt;/code&gt; to &lt;code&gt;comment-region&lt;/code&gt;, and &lt;code&gt;C-c&amp;nbsp;{&lt;/code&gt; set to a function to insert a skeleton class definition.&amp;nbsp; What to do?&amp;nbsp; I finally hit upon &lt;code&gt;C-c&amp;nbsp;(&lt;/code&gt;, and lo-and-behold I had already set that keystroke to toggle &lt;code&gt;c-syntactic-indentation&lt;/code&gt;, sometime in the distant past!  Here&#39;s the code:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  (global-set-key &quot;\C-c(&quot;
                  &#39;(lambda ()
                     (interactive)
                     (setq c-syntactic-indentation (not c-syntactic-indentation))
                     (message &quot;c-syntactic-indentation set to %s&quot;
                              (if c-syntactic-indentation &quot;t&quot; &quot;nil&quot;))))
&lt;/pre&gt;
</description><link>http://softwareengisneering.blogspot.com/2012/09/disabling-auto-indent-in-emacs.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-4042933393016348018</guid><pubDate>Fri, 01 Jun 2012 18:29:00 +0000</pubDate><atom:updated>2012-06-01T11:29:54.749-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">jargon</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Emacs: Scroll Other Window Up</title><description>It often happens that I have two related files open in one emacs frame, and I want to scroll around comparing them.&amp;nbsp; Of course to scroll back and forth in a single buffer, &lt;code&gt;C-v&lt;/code&gt; scrolls you down, and &lt;code&gt;M-v&lt;/code&gt; scrolls you up.  (In a perverse bit of emacs jargon, &lt;code&gt;C-v&#39;s&lt;/code&gt; function is called &quot;scroll-up&quot;, since the text moves &quot;up&quot; relative to the fixed window -- even though every human wanting to look lower in the file thinks and says &quot;scroll down, scroll down&quot; -- and &lt;code&gt;M-v&#39;s&lt;/code&gt; function is called &quot;scroll-down&quot;.)&lt;br /&gt;
&lt;br /&gt;
To keep two files synchronized as you peruse them, the power tool to use is &lt;code&gt;M-x ediff-buffers&lt;/code&gt;, which sets up an interactive diff session to step through the diffs.  Within ediff, a simple lowercase &quot;v&quot; scrolls lower in both files at once, and uppercase &quot;V&quot; scrolls higher.  Don&#39;t forget &lt;code&gt;M-x ediff-revision&lt;/code&gt; as a handy tool for comparing a version-controlled file to its latest revision, or for comparing two different revisions interactively.&lt;br /&gt;
&lt;br /&gt;
Ediff is great, but sometimes it is too heavy-handed for the eyeballing I&#39;m trying to do.  For one thing, if one of the files contains a large section that is missing in the other, scrolling both files at once means striding through the section in one window while inching down a line at a time in the file that lacks it.  Also, navigating ediff can be tedious if there are a great number of changes or reordered chunks, and once your diffs no longer line up sensibly, ediff&#39;s highlighting is simply a nuisance.&lt;br /&gt;
&lt;br /&gt;
So there are the old standbys &lt;code&gt;C-v&lt;/code&gt; and &lt;code&gt;M-v&lt;/code&gt;, plus there is the handy &lt;code&gt;M-C-v&lt;/code&gt;, which scrolls lower in the other window.  That is, if I have a.txt and b.txt open in a single frame, and the cursor is in a.txt, then &lt;code&gt;M-C-v&lt;/code&gt; will show a lower chunk of b.txt, to keep up with &lt;code&gt;C-v&lt;/code&gt; in a.txt.  Until today, whenever I wanted to move &lt;i&gt;higher&lt;/i&gt; in b.txt, I didn&#39;t know of a single keystroke to do that, so I always just switched windows and used &lt;code&gt;M-v&lt;/code&gt;.  I could do &lt;code&gt;C-u - M-C-v&lt;/code&gt;, but I never liked that.&lt;br /&gt;
&lt;br /&gt;
Turns out there is a keystroke to scroll higher in b.txt without switching windows:  &lt;code&gt;M-C-S-v&lt;/code&gt; -- same keys as scrolling lower, plus the shift key.  Now, &lt;code&gt;M-C-v&lt;/code&gt; is a pretty ergonomic companion to &lt;code&gt;C-v&lt;/code&gt;.  I lean the base of my left hand on the Ctrl key, hit V with my left index finger, and keep my thumb poised over the Alt key to choose which window to scroll.  The shift key just does not fit in with this scheme.  With some effort, I can hold it with my left pinkie, but it&#39;s not comfortable.  So my new solution is to tie that command to &lt;code&gt;C-c M-C-v&lt;/code&gt;.  True, it&#39;s not a single keystroke, but unlike the &lt;code&gt;C-u&lt;/code&gt; solution above, it&#39;s all in the left hand, and close together without being cramped.  The .emacs line is:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  (global-set-key &quot;\C-c\M-\C-v&quot; `scroll-other-window-down)
&lt;/pre&gt;
&lt;br /&gt;
Yes, the command to go higher in the file -- to scroll up as we humans say -- is &quot;scroll-other-window-down&quot;.</description><link>http://softwareengisneering.blogspot.com/2012/06/emacs-scroll-other-window-up.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-592415034886633040</guid><pubDate>Fri, 13 Jan 2012 04:03:00 +0000</pubDate><atom:updated>2012-01-12T20:03:40.519-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">gcc</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>gcc error: invalid use of member (did you forget the `&amp;&#39; ?)</title><description>Every time I have gotten the above compilation error, it has nothing to do with a missing ampersand.  Instead, it is missing function-call parentheses:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  if (you_go &amp;&amp; use-&gt;yourMember) { // WRONG!
    this-&gt;isInvalid();
  }

  if (i_go &amp;&amp; use-&gt;myMember()) { // Oh yeah, the parens.
    continue;
  }
&lt;/pre&gt;&lt;br /&gt;
So don&#39;t use your member invalidly.</description><link>http://softwareengisneering.blogspot.com/2012/01/gcc-error-invalid-use-of-member-did-you.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-8318084716450228114</guid><pubDate>Sat, 12 Mar 2011 00:39:00 +0000</pubDate><atom:updated>2011-03-11T16:39:33.032-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">case analysis</category><category domain="http://www.blogger.com/atom/ns#">style</category><title>Don&#39;t Avoid No-ops</title><description>A form of &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/08/eschew-case-analysis.html&quot;&gt;spurious case analysis&lt;/a&gt; that seems to come up a lot in the code I have to work on right now falls under the category of &quot;avoiding a no-op&quot;.  Well, don&#39;t add cruft to your code just to avoid a no-op.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s the one that I see hundreds of:&lt;br /&gt;
&lt;pre&gt;  if (ptr != NULL) {
    delete ptr;
  }
&lt;/pre&gt;Instead of:&lt;br /&gt;
&lt;pre&gt;  delete ptr;
&lt;/pre&gt;But the line that caused me to post this today was this:&lt;br /&gt;
&lt;pre&gt;  if (!isalnum(str[i]) &amp;&amp; (str[i] != &#39;_&#39;)) str[i] = &#39;_&#39;;
&lt;/pre&gt;Why complicate the if condition just to make sure and not overwrite an underscore with an underscore?  In reading through this code I paused to consider when an underscore could occur, and whether something special had to happen, only to read a little further and see that someone was guarding against a no-op.  Good lord, just perform the no-op so I can read this more easily:&lt;br /&gt;
&lt;pre&gt;  if (!isalnum(str[i])) str[i] = &#39;_&#39;;
&lt;/pre&gt;</description><link>http://softwareengisneering.blogspot.com/2011/03/dont-avoid-no-ops.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-1970365816764543762</guid><pubDate>Fri, 28 Jan 2011 01:05:00 +0000</pubDate><atom:updated>2011-04-22T09:46:20.477-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">negative</category><category domain="http://www.blogger.com/atom/ns#">tcl</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Filename Expansion in Tcl</title><description>Stupid, stupid, Tcl.  If you want to run a shell command with a glob filename, like &lt;code&gt;*.h&lt;/code&gt;, you can&#39;t just do:&lt;br /&gt;
&lt;pre&gt;exec ls -l *.h
&lt;/pre&gt;&lt;br /&gt;
You have to explicitly tell Tcl to expand the glob, because it will pass *.h to the shell literally.  But you also can&#39;t do:&lt;br /&gt;
&lt;pre&gt;exec ls -l [glob *.h]
&lt;/pre&gt;&lt;br /&gt;
because it will pass the entire list to the shell literally (thanks, Tcl, that&#39;s useful).  You get lucky and it works if there is exactly one file matched by the glob.  Otherwise &lt;code&gt;ls&lt;/code&gt; will complain that there&#39;s no file called &quot;a.h b.h c.h&quot;.&lt;br /&gt;
&lt;br /&gt;
So what do you do?  Unfortunately, if you pull up the man page for &lt;code&gt;exec&lt;/code&gt; on the internet, it tells you a way to do this that is only syntactically valid for Tcl 8.5 or greater.  For those of us living in the past, the demonic incantation you must utter is:&lt;br /&gt;
&lt;pre&gt;eval [list exec ls -l] [glob *.h]
&lt;/pre&gt;&lt;br /&gt;
Don&#39;t use Tcl unless you have to.</description><link>http://softwareengisneering.blogspot.com/2011/01/filename-expansion-in-tcl.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-3019935944870201478</guid><pubDate>Wed, 26 Jan 2011 20:00:00 +0000</pubDate><atom:updated>2011-01-26T12:19:39.885-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">style</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>C++ Static No Longer Deprecated</title><description>Wow, a long-held piece of geek trivia is no longer true.&lt;br /&gt;&lt;br /&gt;This &lt;a href=&quot;http://stackoverflow.com/questions/4726570/deprecation-of-the-static-keyword-no-more&quot;&gt;Stack Overflow article&lt;/a&gt; points out that in a recent draft of the upcoming &lt;a href=&quot;http://en.wikipedia.org/wiki/C%2B%2B0x&quot;&gt;C++0x&lt;/a&gt; revision to the C++ standard, file-scope &lt;code&gt;static&lt;/code&gt; declarations are no longer deprecated.  For, oh, 20 years, it&#39;s been one of those finer language points that you can whip out to show your sophistication and look down on the ignorant.  But between the August 2010 draft &lt;a href=&quot;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3126.pdf&quot;&gt;(pdf)&lt;/a&gt; and the November 2010 draft &lt;a href=&quot;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3225.pdf&quot;&gt;(pdf)&lt;/a&gt;, the section deprecating &lt;code&gt;static&lt;/code&gt; has been struck!&lt;br /&gt;&lt;br /&gt;If you&#39;re unfamiliar with the issue, it&#39;s that anonymous &lt;code&gt;namespaces&lt;/code&gt; provide a more general solution to the multiply-defined symbol problem.  Instead of:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  static int num = 0;&lt;br /&gt;  static int read_num() { return num; }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;the preferred C++ way to limit visibility of global objects to file scope was:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  namespace {&lt;br /&gt;&lt;br /&gt;  int num = 0;&lt;br /&gt;  int read_num() { return num; }&lt;br /&gt;&lt;br /&gt;  } // anonymous namespace&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The rationale is that you can put other symbols you wish to hide -- like class definitions -- in such a &lt;code&gt;namespace&lt;/code&gt;, but &lt;code&gt;static&lt;/code&gt; doesn&#39;t help you with those.  As the most general solution to the problem, &lt;code&gt;namespace&lt;/code&gt; wins and &lt;code&gt;static&lt;/code&gt; loses.  But I suppose that 20 years of failing to break people of the &lt;code&gt;static&lt;/code&gt; habit led to a recent change of heart.&lt;br /&gt;&lt;br /&gt;Suits me.  I had been consistently using anonymous namespaces for quite a while, both to be modern and especially since it does frequently come up that I want a type that is only used in one file.  But &lt;code&gt;static&lt;/code&gt; declarations are better for self-documenting the code, so I am happy to welcome them back.&lt;br /&gt;&lt;br /&gt;Only problem is, I need a new piece of C++ trivia to show off with.</description><link>http://softwareengisneering.blogspot.com/2011/01/c-static-no-longer-deprecated.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-6645149829144663324</guid><pubDate>Wed, 17 Nov 2010 16:54:00 +0000</pubDate><atom:updated>2010-11-17T08:57:59.683-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">shell</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Emacs: Copy Environment Variable from Shell</title><description>Sometimes I get annoyed when my emacs session has different environment variable settings than some shell buffer I have running in the session.  The most painful is when a Makefile depends on environment settings that I don&#39;t have in my .profile.  Command-name completion in a shell buffer can also be painful if you have changed your path.  And of course I&#39;d like gdb to start up with the correct environment every time -- you can set the variables inside gdb, but that gets old on those days when gdb itself crashes again and again.&lt;br /&gt;
&lt;br /&gt;
I kept pasting &lt;code&gt;export FOO=bar&lt;/code&gt; into the *scratch* buffer and editing it into &lt;code&gt;(setenv &quot;FOO&quot; &quot;bar&quot;)&lt;/code&gt; and eval&#39;ing that.  After the 1000th time of doing that, I decided to automate it.  Turns out emacs already has an interactive function for copying an environment variable from the shell, but you have to type in the variable name.  I decided to write a little function to look for the last export, or the last &lt;code&gt;echo $FOO&lt;/code&gt;, and copy &lt;i&gt;that&lt;/i&gt; variable:&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;font-size:75%; color:black&quot;&gt;(defun engisneering-shell-copy-env-var ()
  (interactive)
  (let* ((expat &quot;\\(export +\\([^=\n]+\\)=\\(.+\\)\\)&quot;)
         (echpat &quot;\\(echo +\\$\\(.+\\)\n\\(.+\\)\\)&quot;)
         (cshpat &quot;\\(setenv +\\([^ \n]+\\) +\\(.+\\)\\)&quot;)
         (patt (concat shell-prompt-pattern
                       &quot;\\(&quot; expat &quot;\\|&quot; echpat &quot;\\|&quot; cshpat &quot;\\)&quot;)))
    (save-excursion
      (if (re-search-backward patt)
          (let* ((m (or (and (match-beginning 2) 3)
                        (and (match-beginning 5) 6) 9))
                 (var (buffer-substring (match-beginning m) (match-end m)))
                 (oldval (or (getenv var) &quot; &quot;)))
            (shell-copy-environment-variable var)
            (setq val (getenv var))
            (message &quot;Old %s=%s; New %s=%s&quot; var oldval var val))))))
&lt;/pre&gt;&lt;br /&gt;
Run this function inside your shell buffer, and it will search backwards for the last environment variable action and bring that variable setting into the emacs session.  It&#39;s also nice because it gives you a message in the minibuffer showing the change.  Add a &lt;code&gt;local-set-key&lt;/code&gt; -- I like &lt;code&gt;C-c C-v&lt;/code&gt; -- in your shell-mode-hook, and you&#39;re good to go.</description><link>http://softwareengisneering.blogspot.com/2010/11/emacs-copy-environment-variable-from.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-3124545604849968314</guid><pubDate>Thu, 23 Sep 2010 02:03:00 +0000</pubDate><atom:updated>2010-09-22T19:03:06.333-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">negative</category><title>Let&#39;s Allocate Stuff!</title><description>Nobody&#39;s perfect, of course, but when there are &lt;i&gt;so&lt;/i&gt; many things wrong with a small piece of C++ code, it&#39;s hard to be placid.  How about:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  std::vector&lt;std::string *&gt; v = new std::vector&lt;std::string *&gt;;
  // ...
    v-&gt;push_back(new std::string(&quot;...&quot;));
  // ...
  std::ostream *str = get_me_a_stream(...);
  for (int i = 0; i &lt; v-&gt;size(); i++) {
    *str &lt;&lt; (*v)[i]-&gt;c_str();
  }
  delete str;
  // loop to delete v and its elements.
&lt;/pre&gt;&lt;br /&gt;
Ow, my head is spinning from all of these needless allocations.  Let&#39;s not wear out new and delete.&lt;br /&gt;
&lt;br /&gt;
Well, if you first learn C and then learn C++, your head might still be in Pointer Land.  But the unnecessary call to c_str() makes it hard for me to get any work done.</description><link>http://softwareengisneering.blogspot.com/2010/09/lets-allocate-stuff.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-8233802266095528467</guid><pubDate>Sun, 15 Aug 2010 00:11:00 +0000</pubDate><atom:updated>2010-08-14T17:11:31.121-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">gcc</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>gcc: error: expected `)&#39; before &#39;&amp;&#39; token</title><description>Duplicate post here just to get two related error messages into page titles.  That&#39;s as much SEO as I know how to do.&lt;br /&gt;
&lt;br /&gt;
If you get this error from g++, and everything looks correct to you, maybe you are defining a constructor without qualifying it with the class name.  See the example on &lt;a href=&quot;http://softwareengisneering.blogspot.com/2010/08/gcc-error-expected-unqualified-id.html&quot;&gt;this post&lt;/a&gt;.</description><link>http://softwareengisneering.blogspot.com/2010/08/gcc-error-expected-before-token.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-1268658945599984020</guid><pubDate>Sat, 14 Aug 2010 23:59:00 +0000</pubDate><atom:updated>2010-08-14T17:58:23.204-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">gcc</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>gcc: error: expected unqualified-id before &#39;)&#39; token</title><description>I was scratching my head for a few minutes over the g++ error message in the title.  Google turned up a couple of red herrings, like &lt;a href=&quot;http://stackoverflow.com/questions/106117/gcc-expected-unqualified-id-before-token&quot;&gt;this one&lt;/a&gt; at Stack Overflow where a clueless noob &lt;code&gt;#defined&lt;/code&gt; the name of his class.&lt;br /&gt;
&lt;br /&gt;
My mistake had been to define a constructor without putting the &lt;code&gt;Class::&lt;/code&gt; in front of it:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
    Class() // WRONG!!!
    : Super(), _duper()
    {
    }
&lt;/pre&gt;&lt;br /&gt;
instead of&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
    Class::Class()
    : Super(), _duper()
    {
    }
&lt;/pre&gt;&lt;br /&gt;
It wasn&#39;t as stupid as it sounds, I was cutting and pasting inlined functions into the .cpp file.</description><link>http://softwareengisneering.blogspot.com/2010/08/gcc-error-expected-unqualified-id.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-65937677953479212</guid><pubDate>Wed, 14 Jul 2010 19:31:00 +0000</pubDate><atom:updated>2010-07-14T12:31:12.820-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">perl</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Can&#39;t Locate Object Method via Package</title><description>I recently got a confusing Perl error message for a line of code that I thought was a simple assignment to a hash member:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;code&gt;Can&#39;t locate object method &quot;patterns&quot; via package &quot;objdir(/[^ ]*)?&quot; (perhaps you forgot to load &quot;objdir(/[^ ]*)?&quot;?) at ./filter.pl line 24.&lt;br /&gt;
&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;
A Google search turned up many forum entries asking about the message, but they all had to do with open-source projects where there was indeed a package method call that had gone wrong.&lt;br /&gt;
&lt;br /&gt;
After I rubbed my eyes long enough, it was obvious what I had done:  left the &#39;$&#39; off the front of the hash reference.  I had typed:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;    patterns{&quot;objdir(/[^ ]*)?&quot;} = &quot;dirs/objs&quot;; # WRONG!
&lt;/pre&gt;&lt;br /&gt;
instead of:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;    $patterns{&quot;objdir(/[^ ]*)?&quot;} = &quot;dirs/objs&quot;;
&lt;/pre&gt;&lt;br /&gt;
I even had &lt;code&gt;use strict; use warnings;&lt;/code&gt; on, but only got the error message.  Anyway, since Google didn&#39;t help me out, let&#39;s see if this page with the error text in the title floats to the top and helps someone else out someday.</description><link>http://softwareengisneering.blogspot.com/2010/07/cant-locate-object-method-via-package.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-7432322333016795444</guid><pubDate>Fri, 18 Jun 2010 21:31:00 +0000</pubDate><atom:updated>2010-06-18T14:56:22.529-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">dead code</category><category domain="http://www.blogger.com/atom/ns#">negative</category><title>Blessed Mother of Commented-out Code</title><description>It&#39;s the little things in life that give pleasure, isn&#39;t it?  Like the lovely comment below, which has adorned a source file at my company for nearly sixteen (16) years now (meaning the file is at least 5 years older than the company).&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;/*****************************#if (0) //[
// Marked code has been deleted   -- XXXX (18 August, 1994)
// No need to check whether the value is X/X/X
// Only the size is to be checked which has been done
[[[ DELETED

      char  val;

      val=tolower(*((char*) var)-&gt;getValue());
      if ((val != &#39;X&#39;) &amp;&amp; (val != &#39;X&#39;) &amp;&amp; (val != &#39;X&#39;))
          return 0;
]]]
   #endif //]
*************************************/
&lt;/pre&gt;&lt;br /&gt;
There are many facets to this beautiful gem.  First you&#39;ll notice that there is a nice C++-style &lt;code&gt;//&lt;/code&gt; comment -- complete with the date and the signature of Mr. XXXX -- itself commented out by a C-style &lt;code&gt;/*&lt;/code&gt; comment.  Too bad the dead code isn&#39;t commented with &lt;code&gt;//&lt;/code&gt;, so that my &lt;code&gt;grep&lt;/code&gt; for &lt;code&gt;tolower&lt;/code&gt; would have stood out as unnecessary.&lt;br /&gt;
&lt;br /&gt;
But look, really the &lt;code&gt;/*&lt;/code&gt; is there to comment out an &lt;code&gt;#if 0&lt;/code&gt;.  The guy must have wanted emacs to colorize the dead code as a comment -- I don&#39;t think emacs had font-lock back then, but there was the hilit19 package.&lt;br /&gt;
&lt;br /&gt;
Still, you can&#39;t be too careful, so let&#39;s also wrap that code up in a &lt;code&gt;[[[DELETED ... ]]]&lt;/code&gt;, in case there is some human that can&#39;t read the C comments and the if-0, but who will understand what &quot;triple-bracket DELETED&quot; means.&lt;br /&gt;
&lt;br /&gt;
Finally, it appears the conditional was originally written as &lt;code&gt;#if (0) [ ... ]&lt;/code&gt; -- was that ever legal C? -- but when that wouldn&#39;t compile, the brackets had to be commented out, because every character in this file is &lt;i&gt;too precious to ever delete&lt;/i&gt;.  This must be the bad code afterlife.  You can check out anytime you like, but you can never leave.&lt;br /&gt;
&lt;br /&gt;
How did all this happen?  Is it an accumulation of different commenting-out strategies that occurred over time?  Or is it just an unfortunate snapshot of one man&#39;s frenzied efforts to remove 3 lines of code without actually deleting anything?  Sadly, we can only speculate on what happened, because these lines entered our repository in exactly this condition over 10 years ago.&lt;br /&gt;
&lt;br /&gt;
I love deleting dead code, but I can&#39;t touch this one.  It&#39;s an antique.  And so ugly that it&#39;s beautiful.</description><link>http://softwareengisneering.blogspot.com/2010/06/blessed-mother-of-commented-out-code.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-6667768817381878814</guid><pubDate>Thu, 10 Jun 2010 23:55:00 +0000</pubDate><atom:updated>2010-06-10T16:57:45.188-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">csh</category><category domain="http://www.blogger.com/atom/ns#">negative</category><title>Csh Skips Last Line in Script</title><description>Oh, joy.&amp;nbsp; I&#39;ve found another thing to &lt;a href=&quot;http://softwareengisneering.blogspot.com/2009/10/csh-dumbness.html&quot;&gt;hate about csh&lt;/a&gt;.&amp;nbsp; If the last line of your script doesn&#39;t have a newline after it, &lt;i&gt;that line won&#39;t be executed&lt;/i&gt;.&amp;nbsp; It will be silently ignored.&amp;nbsp; That isn&#39;t very useful.&lt;br /&gt;
&lt;br /&gt;
If emacs knows you are editing a shell script, it will automatically put a newline at the end if you didn&#39;t do it yourself.&amp;nbsp; But if you have an ordinary text file that you will run with source, it better have a newline at the end.&amp;nbsp; You can get emacs to either ensure that or warn you about it by adding one of the following lines to your .emacs file:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;;; Quietly add a newline if missing.
  (setq require-final-newline t)

  ;; Ask if you want a newline at end of file.
  (setq require-final-newline &#39;ask)
&lt;/pre&gt;&lt;br /&gt;
Googling for this problem, I found another &lt;a href=&quot;http://www.grymoire.com/Unix/CshTop10.txt&quot;&gt;nice csh rant&lt;/a&gt;.</description><link>http://softwareengisneering.blogspot.com/2010/06/csh-skips-last-line-in-script.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-6560951406728726831</guid><pubDate>Wed, 28 Apr 2010 18:50:00 +0000</pubDate><atom:updated>2011-03-11T16:40:29.362-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">case analysis</category><category domain="http://www.blogger.com/atom/ns#">negative</category><category domain="http://www.blogger.com/atom/ns#">tcl</category><title>Tcl Case Analysis Lunacy</title><description>This goes way back to the roots of this blog.  &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/08/tcl-is-toy-language.html&quot;&gt;Complaining about Tcl&lt;/a&gt;, and complaining about code that breaks down into unnecessary and confusing &lt;a href=&quot;http://softwareengisneering.blogspot.com/2008/08/eschew-case-analysis.html&quot;&gt;case analysis&lt;/a&gt; -- those topics were the first three posts here.&lt;br /&gt;
&lt;br /&gt;
Unsurprisingly, the toy language that is Tcl is serving me up some ridiculous case analysis.  It has to do with the C++-side of a Tcl integration.  When you look at the internals of the language objects created by the Tcl interpreter, some things that are conceptually the same have different internal representations.  It&#39;s bad enough that I have to succumb to case analysis to figure out what&#39;s what:  but on the other side of that wall, Tcl had to do some case analysis to put them all in different representations!  Bad, naughty Tcl.&lt;br /&gt;
&lt;br /&gt;
Here&#39;s what&#39;s bugging me.  When you look at a &lt;code&gt;Tcl_Obj&lt;/code&gt; over in the C world, it has a &lt;code&gt;typePtr&lt;/code&gt; member to distinguish different types of things:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;A simple name like &lt;code&gt;A&lt;/code&gt; has a &lt;code&gt;NULL&lt;/code&gt; typePtr.&lt;/li&gt;
&lt;li&gt;So does a list of things in braces, like &lt;code&gt;{ A B }&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A name with some special characters like &lt;code&gt;A[0]&lt;/code&gt; has type &quot;string&quot;.&lt;/li&gt;
&lt;li&gt;So does a list of things in braces which extends over a few lines, like:&lt;br /&gt;
&lt;pre&gt;{ A \
      B }
&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;An explicit list like &lt;code&gt;[list A]&lt;/code&gt; has type &quot;list&quot;.&lt;/li&gt;
&lt;li&gt;A quoted string like &lt;code&gt;&quot;A B&quot;&lt;/code&gt; has &lt;code&gt;NULL&lt;/code&gt;.  At least I think so.  I lost track.&lt;br /&gt;
&lt;/ul&gt;So obviously there are a bunch of &lt;code&gt;if&lt;/code&gt; statements in the back-end tangling stuff up like this.  But it&#39;s nearly impossible to untangle it on the C side.&lt;br /&gt;
&lt;br /&gt;
Stupid Tcl.  Stupid case analysis.</description><link>http://softwareengisneering.blogspot.com/2010/04/tcl-case-analysis-lunacy.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-2584012281797189358</guid><pubDate>Thu, 11 Mar 2010 06:23:00 +0000</pubDate><atom:updated>2010-03-10T22:27:02.868-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">negative</category><category domain="http://www.blogger.com/atom/ns#">style</category><title>Don&#39;t Give Variables Negative Names</title><description>Sometimes programmers get caught up in the absence of something.  Don&#39;t let that leak over into the name of a variable or data member:&lt;br /&gt;
&lt;pre&gt;bool Job::acceptable(const JobCandidate &amp;applicant) const
{
  bool noFelonyConvictions = findFelonyConvictions(applicant);
  return noFelonyConvictions &amp;&amp; qualified(applicant);
}
&lt;/pre&gt;The &lt;code&gt;noFelonyConvictions&lt;/code&gt; variable documents the code in a readable way, but it gets silly if the code ever changes so that you have to initialize it, or if someone ever wants to know if there &lt;i&gt;are&lt;/i&gt; felony convictions.  Things become less readable:&lt;br /&gt;
&lt;pre&gt;  bool noFelonyConvictions = true;
  if (applicant.findRecords(FELONY)) {
    noFelonyConvictions = false;
  }
  return applicant.qualified(!noFelonyConvictions);
&lt;/pre&gt;It all makes more sense if you name the variable &lt;code&gt;felonyConvictions&lt;/code&gt;, which initializes naturally enough to false, can be set to true if one is found, and can be negated to show absence.  Also, if you later become interested in the number of convictions, there will be fewer code changes if the variable changes from a &lt;code&gt;bool&lt;/code&gt; to an &lt;code&gt;int&lt;/code&gt;.&lt;br /&gt;
&lt;br /&gt;
Whenever you notice yourself putting a &quot;no&quot; into a variable name, get rid of it.</description><link>http://softwareengisneering.blogspot.com/2010/03/dont-give-variables-negative-names.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-3165032496881257158</guid><pubDate>Fri, 05 Feb 2010 01:47:00 +0000</pubDate><atom:updated>2010-02-04T17:47:56.903-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bash</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>How to Undeclare a bash Function</title><description>It took me a few minutes to figure this out, so I thought I might as well pass it along.&lt;br /&gt;
&lt;br /&gt;
If you&#39;ve declared a bash function, and then decided you don&#39;t really want it, either because you went ahead and implemented it as a script somewhere, or you gave it a bad name or something, you undeclare it like this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  $ unset -f myfunc
&lt;/pre&gt;</description><link>http://softwareengisneering.blogspot.com/2010/02/how-to-undeclare-bash-function.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-2527614379265305248</guid><pubDate>Tue, 02 Feb 2010 00:29:00 +0000</pubDate><atom:updated>2010-02-01T16:29:22.629-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">c++</category><category domain="http://www.blogger.com/atom/ns#">negative</category><title>Nice Code Structure</title><description>Here&#39;s a brilliant one I just ran across at work (variables changed to protect the... to protect someone):&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  for (i = 0; i &lt; lim; i++) {
    if (someCondition(n[i])) {
      warn(&quot;you can&#39;t do that&quot;);
      continue;
    }
    switch (n[i].type()) {
      default:
        nn = 0;
        warn(&quot;we&#39;re ignoring this&quot;);
        break;
    }
    orig-&gt;doSomethingWith(nn);
    delete nn;
  }
&lt;/pre&gt;&lt;br /&gt;
How do you like that &lt;code&gt;switch&lt;/code&gt; with only a &lt;code&gt;default&lt;/code&gt; branch?  Pretty cool, huh?  Almost is nice is the &lt;code&gt;delete&lt;/code&gt; that only ever sees a &lt;code&gt;NULL&lt;/code&gt;.  Then when I realized &lt;code&gt;doSomethingWith()&lt;/code&gt; is a no-op if it gets a &lt;code&gt;NULL&lt;/code&gt;, I felt even luckier.&lt;br /&gt;
&lt;br /&gt;
Look, if you&#39;re making such a big change to some code that you take out &lt;i&gt;all&lt;/i&gt; the branches of a &lt;code&gt;switch&lt;/code&gt;, isn&#39;t it worth a couple minutes to clean this up and show what is really happening?  After all, the code really does this:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;  for (i = 0; i &lt; lim; i++) {
    if (someCondition(n[i])) {
      warn(&quot;you can&#39;t do that&quot;);
    }
    else {
      warn(&quot;we&#39;re ignoring this&quot;);
    }
  }
&lt;/pre&gt;

It probably makes sense to only give the second warning, since who cares if you can&#39;t do it, when really it would only be ignored anyway.  And at that point you might wonder why you need to give the same warning &lt;code&gt;lim&lt;/code&gt; times.&lt;br /&gt;
&lt;br /&gt;
Ugly code kills.  Kill ugly code.</description><link>http://softwareengisneering.blogspot.com/2010/02/nice-code-structure.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-1799461363142636897</guid><pubDate>Fri, 11 Dec 2009 17:43:00 +0000</pubDate><atom:updated>2009-12-11T09:54:48.490-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">shell</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Emacs vs. Nicer dirs</title><description>In the last post I described a &lt;a href=&quot;http://softwareengisneering.blogspot.com/2009/11/nicer-pushd-popd-and-dirs.html&quot;&gt;nicer version&lt;/a&gt; of the shell &lt;code&gt;dirs&lt;/code&gt; command that labels each directory with its position, so that you can &lt;code&gt;pushd&lt;/code&gt; directly to the one you want.&lt;br /&gt;&lt;br /&gt;One problem with it is that emacs shell-mode generally uses &lt;code&gt;dirs&lt;/code&gt; to track which directory you&#39;re in.  And you do want it to track directories for you.  Our nicer version of &lt;code&gt;dirs&lt;/code&gt; produces output that isn&#39;t readable to emacs.&lt;br /&gt;&lt;br /&gt;Of course the natural solution is:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; (setq shell-dirstack-query &quot;command dirs&quot;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;to pick up the shell&#39;s builtin &lt;code&gt;dirs&lt;/code&gt;.  Sadly, you can&#39;t just throw that line into your .emacs file, because shell-mode sets &lt;code&gt;shell-dirstack-query&lt;/code&gt; every time you start a new shell.  It sets it &lt;span style=&quot;font-style: italic;&quot;&gt;unconditionally and globally&lt;/span&gt;, which is a ridiculous design flaw, but that&#39;s how it goes.  There is no hook that runs after it sets the value, either.&lt;br /&gt;&lt;br /&gt;So you&#39;re stuck with needing a workaround:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Name your command something other than &lt;code&gt;dirs&lt;/code&gt; .&lt;/li&gt;&lt;li&gt;Use a flag on your new &lt;code&gt;dirs&lt;/code&gt; to get the nicer behavior.&lt;/li&gt;&lt;li&gt;Write your own emacs function to start a shell:&lt;/li&gt;&lt;/ol&gt;&lt;pre&gt;&lt;br /&gt;  (defun engisneering-shell ()&lt;br /&gt;    (interactive)&lt;br /&gt;    (shell)&lt;br /&gt;    (setq shell-dirstack-query &quot;command dirs&quot;))&lt;br /&gt;&lt;/pre&gt;</description><link>http://softwareengisneering.blogspot.com/2009/12/emacs-vs-nicer-dirs.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-6847961066189305331</guid><pubDate>Wed, 18 Nov 2009 00:38:00 +0000</pubDate><atom:updated>2009-12-11T09:57:32.255-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bash</category><category domain="http://www.blogger.com/atom/ns#">shell</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Nicer pushd, popd, and dirs</title><description>Writing up the safer, friendlier &lt;a href=&quot;http://softwareengisneering.blogspot.com/2009/10/bash-vs-which.html&quot;&gt;bash &lt;code&gt;which&lt;/code&gt;&lt;/a&gt; command reminded me of another wrapper function that&#39;s handy to have.  If you use &lt;code&gt;pushd/popd&lt;/code&gt; to keep a stack of directories in your shell window, sometimes you want to switch to a directory far down the stack.  If you want to switch to the third directory down, you do &lt;code&gt;pushd +3&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;The problem is, you have to count along the list of directories, since &lt;code&gt;dirs, pushd,&lt;/code&gt; and &lt;code&gt;popd&lt;/code&gt; all just spit out a one-line list of the stack, like this:&lt;pre&gt;&lt;br /&gt;  $ dirs&lt;br /&gt;  /usr/local/share ~ ~/work ~/tmp&lt;br /&gt;&lt;/pre&gt;Not an impossible task, but it can get annoying if you have some long paths in there, especially once your stack gets past two or three deep.  Why not have &lt;code&gt;dirs&lt;/code&gt; print one directory per line, and label them with their depths?  To do so, add this function to your &lt;code&gt;.bashrc&lt;/code&gt; file:&lt;pre&gt;&lt;br /&gt;  function dirs {&lt;br /&gt;      ds=(`command dirs`)&lt;br /&gt;      i=0&lt;br /&gt;      while [ &quot;${ds[$i]}&quot; != &quot;&quot; ]; do&lt;br /&gt;          echo $i: ${ds[$i]};&lt;br /&gt;          i=$((i+1));&lt;br /&gt;      done&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;Now you get more readable output:&lt;pre&gt;&lt;br /&gt;  $ dirs&lt;br /&gt;  0: /usr/local/share&lt;br /&gt;  1: ~&lt;br /&gt;  2: ~/work&lt;br /&gt;  3: ~/tmp&lt;br /&gt;&lt;/pre&gt;If you want to remove &lt;code&gt;~/work&lt;/code&gt; from the stack, just do &lt;code&gt;popd +2&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;Since &lt;code&gt;pushd&lt;/code&gt; and &lt;code&gt;popd&lt;/code&gt; also print the directory stack, let&#39;s add the same style of output to them:&lt;pre&gt;&lt;br /&gt;  function pushd {&lt;br /&gt;      if command pushd $@ &gt; /dev/null; then&lt;br /&gt;          dirs&lt;br /&gt;      fi&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  function popd {&lt;br /&gt;      if command popd $@ &gt; /dev/null; then&lt;br /&gt;          dirs&lt;br /&gt;      fi&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;One final note.  In case some wacky systemwide file has aliased these commands to something else, add the following unaliasing code to the top of your .bashrc:&lt;pre&gt;&lt;br /&gt;  for func in dirs pushd popd; do&lt;br /&gt;      if alias $func &gt; /dev/null 2&gt;&amp;1 ; then unalias $func; fi&lt;br /&gt;  done&lt;br /&gt;&lt;/pre&gt;Otherwise, your functions will be hidden (aliases take precedence).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;PS: emacs shell-mode has a conflict with this dirs:&lt;/span&gt; here&#39;s how to &lt;a href=&quot;http://softwareengisneering.blogspot.com/2009/12/emacs-vs-nicer-dirs.html&quot;&gt;fix it&lt;/a&gt;.</description><link>http://softwareengisneering.blogspot.com/2009/11/nicer-pushd-popd-and-dirs.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-7758925682850841169</guid><pubDate>Mon, 02 Nov 2009 18:05:00 +0000</pubDate><atom:updated>2009-11-02T11:07:14.375-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">emacs</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Keep from Killing Emacs Shell Buffers</title><description>If you&#39;re someone who lives in emacs like I do, then you probably rely on shell buffers (&lt;code&gt;M-x shell&lt;/code&gt;) to interact with the operating system.  That way you can search through output and edit history commands in a natural way that a mere terminal doesn&#39;t allow.&lt;br /&gt;&lt;br /&gt;But occasionally I&#39;ve been left kicking the wall after accidentally killing a shell buffer that had lots of work in it that I still needed.  It really hurts when you accidentally kill a buffer where you&#39;re waiting for a long-running process to finish.  To prevent industrial accidents like that, add a guard to &lt;code&gt;kill-buffer-hook&lt;/code&gt; in your .emacs file:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  (add-hook &#39;kill-buffer-hook&lt;br /&gt;    &#39;(lambda()&lt;br /&gt;       (and&lt;br /&gt;         (string= &quot;Shell&quot; mode-name)&lt;br /&gt;         (or&lt;br /&gt;           (yes-or-no-p&lt;br /&gt;             (format &quot;Kill buffer `%s&#39;? &quot; (buffer-name)))&lt;br /&gt;           (error &quot;Aborted&quot;)))))&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If you really &lt;i&gt;do&lt;/i&gt; want to kill the shell buffer, type &quot;yes&quot;, and you&#39;re done.  But it will save you some grief if you just hit &lt;code&gt;C-x k&lt;/code&gt; in the wrong buffer.&lt;br /&gt;&lt;br /&gt;What&#39;s more common for me is that my eyes are on a file that I want to refresh or replace with &lt;code&gt;C-x C-v (find-alternate-file)&lt;/code&gt;, but the cursor is in a shell buffer.  In that case, emacs will indeed load the alternate file, and you&#39;ll be asked &quot;Kill buffer ` **lose**&#39;?&quot;  Say no, then you&#39;ll have &lt;code&gt;C-x b&lt;/code&gt; to &quot; **lose**&quot; (note the leading space), and rename the shell buffer to &quot;*shell*&quot; or whatever you had previously named it.</description><link>http://softwareengisneering.blogspot.com/2009/11/keep-from-killing-emacs-shell-buffers.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-837664636726682837.post-5099015712087970393</guid><pubDate>Mon, 26 Oct 2009 20:03:00 +0000</pubDate><atom:updated>2009-11-17T16:26:00.409-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">bash</category><category domain="http://www.blogger.com/atom/ns#">shell</category><category domain="http://www.blogger.com/atom/ns#">tips</category><title>Bash vs. Which</title><description>The Unix &lt;code&gt;which&lt;/code&gt; command is useful for searching your &lt;code&gt;$PATH&lt;/code&gt; to find which version of an executable is going to run.  But did you know that it doesn&#39;t always tell you the truth?  For instance, it doesn&#39;t tell you when the command you&#39;re asking about is hidden by a shell builtin (or function, keyword, or alias):&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  $ which echo&lt;br /&gt;  /usr/bin/echo&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;which&lt;/code&gt; found /usr/bin/echo on your path, but &lt;code&gt;echo&lt;/code&gt; is a shell builtin (at least in bash), so that&#39;s what will get run, not the one on the path.  The GNU man page for &lt;code&gt;which&lt;/code&gt; presents workarounds that will pick up functions and aliases, but shell builtins still slip through the cracks.  The situation is even weirder on Solaris, where &lt;code&gt;which&lt;/code&gt; is a &lt;b&gt;csh&lt;/b&gt; shell-script, that sources your &lt;code&gt;.cshrc&lt;/code&gt; file as part of its operation -- very strange if your shell is bash.&lt;br /&gt;&lt;br /&gt;Clearly, &lt;code&gt;which&lt;/code&gt; is not to be trusted.  The easiest workaround, if you use bash, is the &lt;code&gt;type&lt;/code&gt; builtin:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  $ type -a echo&lt;br /&gt;  echo is a shell builtin&lt;br /&gt;  echo is /bin/echo&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;A slightly nicer workaround is to make a &lt;code&gt;bash&lt;/code&gt; function for &lt;code&gt;which&lt;/code&gt;, that uses &lt;code&gt;type&lt;/code&gt; to do the right thing.  I also like &lt;code&gt;which&lt;/code&gt; to do an &lt;code&gt;ls -l&lt;/code&gt; where applicable.  Here&#39;s what I have in my .bashrc:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  if alias which &gt; /dev/null 2&gt;&amp;1; then unalias which; fi&lt;br /&gt;&lt;br /&gt;  function which {&lt;br /&gt;      hash -r&lt;br /&gt;      t=`type -t $@`&lt;br /&gt;&lt;br /&gt;      if [ -z &quot;${t%%file*}&quot; ]; then&lt;br /&gt;          for p in `type -p $@`; do&lt;br /&gt;              ls -l ${p};&lt;br /&gt;          done&lt;br /&gt;      else&lt;br /&gt;          type $@;&lt;br /&gt;      fi&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now &lt;code&gt;which&lt;/code&gt; gives you much more information:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  $ which -a wish&lt;br /&gt;  lrwxrwxrwx  1 root  root  13 Dec 23 2008 /usr/local/bin/wish -&gt; /usr/bin/wish*&lt;br /&gt;  lrwxrwxrwx  1 root  root   7 Jan  8 2007 /usr/bin/wish -&gt; wish8.3*&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The unalias protects you in case some systemwide .bashrc or .profile aliases which in some way (unlikely, but good hygiene anyway).  The call to &lt;code&gt;hash&lt;/code&gt; clears the hashed function list, so that any changes to your PATH are reflected.  The reason for the &lt;code&gt;if&lt;/code&gt; statement in the function, is that we certainly want to report builtins, functions, etc., but if there are none, we can use &lt;code&gt;type -p&lt;/code&gt; to make it easier to pass the filenames to &lt;code&gt;ls -l&lt;/code&gt;.  If there are builtins or such, we just punt and give the unaltered &lt;code&gt;type&lt;/code&gt; output.&lt;br /&gt;&lt;br /&gt;You can pass &lt;code&gt;-a&lt;/code&gt; to this &lt;code&gt;which&lt;/code&gt; if you want to see all the matches for the command, in order of precedence.&lt;br /&gt;&lt;br /&gt;Note that this has to be a function, not a script, because running the script will source your .bashrc, which might change the PATH (all PATH changes should be in .profile, but sometimes people do it in .bashrc).</description><link>http://softwareengisneering.blogspot.com/2009/10/bash-vs-which.html</link><author>noreply@blogger.com (Bill Night)</author><thr:total>0</thr:total></item></channel></rss>