Subject: bug#18846: 24.4; isatty fix in revision 114730 breaks in shell scripts

From: William Lederer <[email-masked]>
Date: Sun, 26 Oct 2014 17:33:45 -0500

Maintainers:

In emacs 24.4 built for mac os x, if I invoke emacs from a command
line, it properly remembers the current directory.  However, if I launch
it from a shell script called from the command line, it forgets the
current directory and goes to the home directory. This happens even if
the --chdir option is used on the command line.

If the command 

/Applications/Emacs.app/Contents/MacOS/Emacs &

is launched from an interactive shell, all is well.  If it is launched
from an executable script ~/bin/ea

#!/bin/bash
/Applications/Emacs.app/Contents/MacOS/Emacs --chdir `pwd` --title "`basename $PWD` hosted `hostname`"  &

emacs ends up in the home directory.

In GNU Emacs 24.4.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
of 2014-10-20 on builder10-9.porkrind.org
Windowing system distributor `Apple', version 10.3.1343
Configured using:
`configure --with-ns'

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Dired by name

Minor modes in effect:
  diff-auto-refine-mode: t
  show-paren-mode: t
  global-hi-lock-mode: t
  hi-lock-mode: t
  desktop-save-mode: t
  display-time-mode: t
  tooltip-mode: t
  electric-indent-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
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t

Recent input:
<help-echo> C-x RET r e p o r t - e m a <tab> <ret
urn>

Recent messages:
Using vacuous schema [7 times]
Setting up indent for shell type sh
Indentation variables are now local.
Indentation setup for shell type sh
Setting up indent for shell type bash
Indentation variables are now local.
Indentation setup for shell type bash
Wrote /Users/wgl/projects/kismet-logging/.emacs.desktop.lock
Desktop: 1 frame, 44 buffers restored.
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
/Users/wgl/.emacs.d/elpa/magit-20141025.429/magit hides /usr/local/share/emacs/site-lisp/magit
/Users/wgl/.emacs.d/elpa/magit-20141025.429/magit-wip hides /usr/local/share/emacs/site-lisp/magit-wip
/Users/wgl/.emacs.d/elpa/magit-20141025.429/magit-key-mode hides /usr/local/share/emacs/site-lisp/magit-key-mode
/Users/wgl/.emacs.d/elpa/magit-20141025.429/magit-blame hides /usr/local/share/emacs/site-lisp/magit-blame
/Users/wgl/quicklisp/dists/quicklisp/software/slime-2.8/contrib/bridge hides /Users/wgl/.emacs.d/elisp/bridge
/Users/wgl/.emacs.d/elisp/tree-widget hides /Applications/Emacs.app/Contents/Resources/lisp/tree-widget
~/.emacs.d/elisp/remember-2.0/remember hides /Applications/Emacs.app/Contents/Resources/lisp/textmodes/remember
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org hides /Applications/Emacs.app/Contents/Resources/lisp/org/org
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-w3m hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-w3m
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-timer hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-timer
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-table hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-table
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-src hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-src
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-rmail hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-rmail
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-protocol hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-protocol
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-plot hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-plot
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-pcomplete hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-pcomplete
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-mouse hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mouse
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-mobile hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mobile
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-mhe hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-mhe
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-macs hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-macs
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-list hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-list
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-irc hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-irc
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-install hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-install
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-inlinetask hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-inlinetask
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-info hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-info
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-indent hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-indent
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-id hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-id
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-habit hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-habit
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-gnus hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-gnus
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-footnote hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-footnote
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-feed hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-feed
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-faces hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-faces
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-eshell hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-eshell
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-entities hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-entities
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-docview hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-docview
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-datetree hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-datetree
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-ctags hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-ctags
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-crypt hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-crypt
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-compat hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-compat
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-colview hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-colview
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-clock hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-clock
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-capture hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-capture
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-bibtex hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-bibtex
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-bbdb hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-bbdb
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-attach hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-attach
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-archive hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-archive
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/org-agenda hides /Applications/Emacs.app/Contents/Resources/lisp/org/org-agenda
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-tangle hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-tangle
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-table hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-table
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-sqlite hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sqlite
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-sql hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sql
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-shen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-shen
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-sh hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sh
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-screen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-screen
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-scheme hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-scheme
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-sass hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-sass
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-ruby hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ruby
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-ref hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ref
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-R hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-R
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-python hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-python
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-plantuml hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-plantuml
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-picolisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-picolisp
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-perl hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-perl
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-org hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-org
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-octave hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-octave
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-ocaml hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ocaml
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-mscgen hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-mscgen
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-maxima hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-maxima
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-matlab hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-matlab
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-lob hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lob
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-lisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lisp
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-lilypond hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-lilypond
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-ledger hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ledger
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-latex hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-latex
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-keys hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-keys
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-js hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-js
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-java hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-java
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-haskell hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-haskell
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-gnuplot hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-gnuplot
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-fortran hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-fortran
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-exp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-exp
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-eval hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-eval
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-emacs-lisp hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-emacs-lisp
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-dot hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-dot
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-ditaa hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-ditaa
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-css hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-css
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-comint hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-comint
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-clojure hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-clojure
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-calc hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-calc
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-C hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-C
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-awk hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-awk
/Users/wgl/.emacs.d/elisp/org-7.8.11/lisp/ob-asymptote hides /Applications/Emacs.app/Contents/Resources/lisp/org/ob-asymptote

Features:
(shadow sort gnus-util mail-extr emacsbug vc-hg conf-mode nxml-uchnm
rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc rng-uri
rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok
generic sh-script smie executable make-mode vc-dispatcher vc-svn vc-git
package epg-config zenburn color-theme sendmail reporter git ewoc
paredit geiser-load geiser org-remember org-datetree org ob-emacs-lisp
ob-tangle ob-ref ob-lob ob-table org-footnote org-src ob-comint ob-keys
ob ob-eval org-pcomplete pcomplete org-list org-faces org-compat
org-entities org-macs cal-menu calendar cal-loaddefs remember-autoloads
psvn wid-edit log-edit message format-spec rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util
add-log diff-mode ediff-merg ediff-wind ediff-diff ediff-mult ediff-help
ediff-init ediff-util dired-x dired html-mode jsp-html-helper-mode
asp-html-helper-mode php-html-helper-mode html-helper-mode tempo cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs generic-x w3m-load slime-banner slime-asdf grep slime-fancy
slime-trace-dialog slime-fontifying-fu slime-package-fu slime-references
slime-compiler-notes-tree slime-scratch slime-presentations bridge
slime-fuzzy slime-fancy-trace slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc advice eldoc slime-repl elp
slime-parse slime byte-opt bytecomp byte-compile cconv derived help-fns
gud compile apropos etags arc-mode archive-mode noutline outline
easy-mmode easymenu pp comint ansi-color ring hyperspec cl-macs
thingatpt browse-url cl gv slime-autoloads go-mode-load edmacro kmacro
saveplace paren ido hi-lock desktop frameset cl-loaddefs cl-lib
cus-start cus-load time time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar 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 minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process cocoa ns
multi-tty emacs)

Memory information:
((conses 16 486290 40349)
(symbols 48 42394 0)
(miscs 40 5406 113)
(strings 32 92062 15570)
(string-bytes 1 2516152)
(vectors 16 31655)
(vector-slots 8 671010 26748)
(floats 8 374 497)
(intervals 56 17829 0)
(buffers 960 56))