Subject: bug#7079: 24.0.50; shelling out picks up ghost error about find

From: Joseph Brenner <[email-masked]>
Date: Mon, 20 Sep 2010 16:22:40 -0700

I often see elisp code using things such as compile-command returning
spurious errors from a "find" shell command which was not run.

Recipie:

(1) With the following elisp in the file ~/tmp/baby-perlnow.el:

  (provide 'baby-perlnow)
  (defun perlnow-run-check ()
    "Run a perl check on the current buffer."
    (interactive)
    (let* ( (full-file (buffer-file-name))
            (location (file-name-directory full-file))
            (filename (file-name-nondirectory full-file))
            (default-directory location)
            )
      (save-buffer)
      (setq compile-command
            (format "perl -Mstrict -cw \'%s\'" filename))
      (compile compile-command)
      ))

(2) And with some perl code such as ~/tmp/Dummy.pm:

  package Dummy;
  use 5.008;
  use strict;
  use warnings;

  sub whatever {
    print "whatever\n";
  }
  1;

(3) Then run emacs like so:

  emacs -Q -l ~/tmp/baby-perlnow.el ~/tmp/Dummy.pm

And do an:
  ESC-x perlnow-run-check

(4) In the *compilation* buffer, you may see something like:

  -*- mode: compilation; default-directory: "~/tmp/" -*-
  Compilation started at Mon Sep 20 10:52:28

  perl -Mstrict -cw 'Dummy.pm'
  find: paths must precede expression: Rep.pm
  Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
  Dummy.pm syntax OK

  Compilation finished at Mon Sep 20 10:52:28

Note that nothing is actually running a "find" command here, and
yet we see the error message from find.

You can verify that the perl check command is not causing the
problem by doing this in a shell window:

  cd ~/tmp
  perl -Mstrict -cw 'Dummy.pm'
  Dummy.pm syntax OK

Note that the find error is referring to some other file, Rep.pm
which as it happens *was* being edited in another emacs process
but not *this* one.

The only buffers open in the -Q emacs are:

.   Dummy.pm                95  Perl		  ~/tmp/Dummy.pm
    *scratch*              191  Lisp Interaction
  * *Messages*              89  Fundamental

I've seen this behavior in a number of contexts... perhaps
notably in the Emacs::Rep code (still under development) which
does some "shell-command-to-string" calls internally.

In GNU Emacs 24.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.16.1)
 of 2010-09-19 on fineline
Windowing system distributor `The X.Org Foundation', version 11.0.10600000
configured using `configure  '--prefix' '/usr/local/emacs/bzr-091910-182331''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: MH-Folder

Minor modes in effect:
  hl-line-mode: t
  shell-dirtrack-mode: t
  show-paren-mode: t
  display-time-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-a C-n C-n C-n C-e o h SPC b o y , SPC b a d SPC E
R R S-SPC m e s s a g e s C-a C-n C-n C-n C-n A r e
SPC y o u SPC t h e r e < <backspace> ? S-SPC SPC J
u s t SPC c h e c k i n g . SPC SPC M e SPC g e t t
i n g SPC a b d SPC <backspace> <backspace> <backspace>
<backspace> b a a d SPC l o <backspace> <backspace>
<backspace> <backspace> a d SPC l o g i n SPC m a <backspace>
e s s a g e s SPC <return> o u t SPC o f SPC n m h
SPC i n c , SPC m e SPC t h i n g s . <backspace> <backspace>
<backspace> k s . C-x C-b C-x o C-n C-n <escape> >
C-p f C-x K <return> C-p C-p f C-x K <return> C-p f
C-r E R R C-a C-r C-r C-p C-a <escape> < C-v C-v C-v
C-x 0 . . SPC a n d SPC y e t SPC m y SPC " i " SPC
w o k <backspace> r k s SPC a s SPC a l w a y s . C-a
C-n C-n C-c C-c C-x 1 <escape> > i C-x o C-p . C-x
o C-x 2 C-x o M-x s h e l l <return> i n c <return>
C-x C-p C-x C-p i C-x o C-p C-p C-p C-p C-l C-n . o
C R O N SPC <return> x i C-x o C-p . M-x r e p o r
t SPC e m a c s SPC b u SPC <return>

Recent messages:
Scanning +inbox...done
No current message
Scanning +FIRST...done
Scanning +FIRST...done
Scanning +SECOND...done
No current message
Scanning +SECOND...done
No current message
Mark set [3 times]
doom-mh-show msg: 6109

Load-path shadows:
/home/doom/End/Cave/DesktopAutosave/lib/emacs/desktop-recover-setup hides /home/doom/lib/emacs/Dots/desktop-recover-setup
/home/doom/End/Cave/DiredExternalApps/lib/emacs/image-dired hides /home/doom/lib/emacs/image-dired
/home/doom/End/Cave/DiredExternalApps/lib/emacs/dired-external-apps hides /home/doom/lib/emacs/dired-external-apps
/home/doom/lib/emacs/Dots/setup-colors-dark hides /home/doom/lib/emacs/setup-colors-dark
/home/doom/End/Cave/DiredExternalApps/lib/emacs/image-dired hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/image-dired
/home/doom/lib/emacs/Dots/strokes hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/strokes
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-thread hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-thread
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-funcs hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-funcs
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-alias hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-alias
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-letter hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-letter
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-buffers hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-buffers
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-print hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-print
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-mime hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-mime
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-xface hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-xface
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-junk hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-junk
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-identity hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-identity
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-tool-bar hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-tool-bar
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-gnus hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-gnus
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-limit hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-limit
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-scan hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-scan
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-loaddefs hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-loaddefs
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-show hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-show
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-folder hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-folder
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-search hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-search
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-seq hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-seq
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-e hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-e
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-comp hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-comp
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-compat hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-compat
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-utils hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-utils
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-inc hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-inc
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-speed hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-speed
/usr/local/emacs/cvs-040510/share/emacs/23.1.90/lisp/mh-e/mh-acros hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/mh-e/mh-acros
/home/doom/lib/emacs/Dots/gnus-setup hides /usr/local/emacs/bzr-091910-182331/share/emacs/24.0.50/lisp/gnus/gnus-setup

Features:
(shadow sort emacsbug mh-search mh-alias crm mail-extr mh-mime
multi-isearch mule-util mh-identity mh-letter executable mh-show
goto-addr gnus-cite gnus-art mm-uu mml2015 epg-config gnus-sum nnoo
gnus-group time-date gnus-undo nnmail mail-source format-spec gnus-start
gnus-spec gnus-int message rfc822 gmm-utils mailheader gnus-win
gnus-range gnus gnus-ems nnheader mail-utils mh-seq mh-inc hl-line
mh-tool-bar mh-xface mh-utils mh-folder which-func imenu thingatpt
desktop desktop-recover desktop-recover-setup finder-inf package
doom-fineline ansi-color registers-defined image-mode junk-dired
junk-setup datestamps live-dangerously strokes macroman doom-filters
find_and_replace json rep rep-setup doom-mh mh-comp sendmail mh-scan
mh-gnus mml mml-sec mm-view smime password-cache dig mailcap mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr gnus-util mh-e mh-compat mailabbrev mh-acros
mh-buffers mh-loaddefs mhe-setup-x pic fugly-keystroke-macros
dired-imagery-doomery-keystroke-macros image-dired thinknow picture
doomfile doomfiles-hacking-setup caving-setup w3m-load html-setup
perlnow-x perlnow template perlnow-setup sepia sepia-cpan sepia-ido ido
sepia-tree tree-widget sepia-w3m w3m-perldoc w3m browse-url timezone
w3m-hist w3m-e22 wid-edit w3m-ccl ccl w3m-fsf w3m-favicon w3m-image
w3m-proc w3m-util gud easy-mmode cperl-mode easymenu sepia-setup
apache-dev perl-setup elisp-hacking-setup doom-print printer-setup
shell-setup perlups derived byte-opt bytecomp byte-compile jka-compr
find-func timeclock-x timeclock timeclock-setup shell comint ring
dired-external-apps ls-lisp dired-sort-map dired-setup save-to-registers
basic-keymap-changes paracide redroot simple-color-change
setup-colors-dark move-frame man-apropos edmacro kmacro zoom-frm
frame-cmds frame-fns avoid zoom-frm-setup text-setup dired-x dired-aux
dired regexp-opt paren uniquify advice help-fns advice-preload warnings
server time emacs-setup cl cl-19 load-path-setup tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core
frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help
simple abbrev loaddefs button minibuffer faces cus-face files
text-properties overlay md5 base64 format env code-pages mule custom
widget hashtable-print-readable backquote make-network-process dbusbind
dynamic-setting system-font-setting font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)