unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes
@ 2013-01-03 20:31 Johan Claesson
  2013-01-04  9:44 ` Andreas Schwab
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Johan Claesson @ 2013-01-03 20:31 UTC (permalink / raw)
  To: 13350

[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]



emacs -Q
M-x ansi-term
/bin/bash
cd /tmp
printf '%4090s' x

On my system this gives the error message:

error in process filter: No such directory found via CDPATH environment variable

I think the following is happening:

- Bash will after each command send ?\032 and the current directory
  "/tmp" to inform term.el. 
- Bash output is buffered in 4096 bytes chunks.  The end of the first
  chunk will be "/tm"
- term.el interprets "/tm" as the current directory and tries to cd
  there.  Since /tm does not exist it signals an error.

I don't know if this buffer size of 4096 varies from system to system.
In that case maybe the above recipe will not trigger the error on all
systems. 

The following term.el patch is an attempt to fix this:

--- original/term.el	2013-01-03 20:33:13.862726000 +0100
+++ elisp/term.el	2013-01-03 20:35:02.374726000 +0100
@@ -2895,11 +2895,11 @@
 			  (beep t))
 			 ((and (eq char ?\032)
                                (not handled-ansi-message))
-			  (let ((end (string-match "\r?$" str i)))
+			  (let ((end (string-match "\r?\n" str i)))
 			    (if end
 				(funcall term-command-hook
 					 (prog1 (substring str (1+ i) end)
-					   (setq i (match-end 0))))
+					   (setq i (1- (match-end 0)))))
 			      (setq term-terminal-parameter (substring str i))
 			      (setq term-terminal-state 4)
 			      (setq i str-length))))


I guess that all 032 escape sequences ends with a newline and that this
is what the regex wants to detect.  But the current regex "\r?$" will
match all strings.  And therefore the mechanism for saving the first
part of the command until the second part arrives will never run.

Regards,

/Johan







[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: term.patch --]
[-- Type: text/x-diff, Size: 626 bytes --]

--- original/term.el	2013-01-03 20:33:13.862726000 +0100
+++ elisp/term.el	2013-01-03 20:35:02.374726000 +0100
@@ -2895,11 +2895,11 @@
 			  (beep t))
 			 ((and (eq char ?\032)
                                (not handled-ansi-message))
-			  (let ((end (string-match "\r?$" str i)))
+			  (let ((end (string-match "\r?\n" str i)))
 			    (if end
 				(funcall term-command-hook
 					 (prog1 (substring str (1+ i) end)
-					   (setq i (match-end 0))))
+					   (setq i (1- (match-end 0)))))
 			      (setq term-terminal-parameter (substring str i))
 			      (setq term-terminal-state 4)
 			      (setq i str-length))))

[-- Attachment #3: Type: text/plain, Size: 9502 bytes --]




In GNU Emacs 24.2.1 (i686-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-03 on goblin
Windowing system distributor `The X.Org Foundation', version 11.0.11203000
Configured using:
 `configure '--prefix=/home/jcl/usr' '--without-toolkit-scroll-bars'
 '-C' '--disable-maintainer-mode' '--without-compress-info''

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: Buffer Menu

Minor modes in effect:
  global-cwarn-mode: t
  which-function-mode: t
  display-time-mode: t
  icomplete-mode: t
  minibuffer-depth-indicate-mode: t
  diff-auto-refine-mode: t
  shell-dirtrack-mode: t
  ido-everywhere: t
  electric-layout-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<up> <up> <up> <up> <down> <return> <C-tab> C-q C-q 
SPC C-r <return> C-n C-n C-n C-n C-n C-n C-n <tab> 
C-a C-k C-k C-k C-k C-k C-k C-k C-k C-x C-s <C-tab> 
<up> <return> <C-tab> <C-tab> <return> <return> <return> 
<C-tab> M-x m a n <return> d i f f <return> C-s n a 
u r <end> M-x m a n <return> p a t c h <return> C-s 
C-s <C-tab> d i f f SPC - N a u r SPC o r i <tab> <tab> 
e l i <tab> t e r <tab> C-) SPC t e r m . p a t c h 
<return> C-x C-f C-f t e r <return> <C-tab> M-x r e 
p o r t - e m <tab> b <tab> - q <tab> <return> <return> 
C-g M-x <up> <return> q <C-tab> <C-tab> c d <backspace> 
<S-backspace> C D P A T H SPC t e r m <return> <tab> 
<return> <up> <down> <right> <right> <return> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <left> C-x o C-x C-b <down-mouse-2> 
<mouse-movement> <mouse-2> <C-tab> M-x f i n d - f 
u n <tab> <return> r e p l <backspace> o r t - e m 
<tab> b u <tab> - <tab> q <tab> <return> <down> <down> 
<down> <down> <down> <down> <down> <down> M-f C-s C-d 
C-r C-r <C-down> <down> <down> <down> <down> C-s C-d 
C-s C-s <C-down> <C-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <C-M-down> <C-M-down> 
<C-M-down> <C-M-down> <C-M-down> <prior> <prior> <prior> 
<prior> <prior> <prior> <prior> <prior> <prior> <prior> 
<prior> <next> <next> <next> <C-tab> M-x <up> <down> 
r e p o r t - e m <tab> b <tab> <return>

Recent messages:
Quit
call-interactively: Buffer is read-only: #<buffer *Existing Emacs Bugs*>
Contacting host: debbugs.gnu.org:80
Reporting new bug! [2 times]
Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %; q to quit; ? for help.
Reporting new bug!
Making completion list...
Mark saved where search started [2 times]
scroll-down: Beginning of buffer [2 times]
Reverting buffer `procmail_inbox'.

Load-path shadows:
/home/jcl/elisp/term hides /home/jcl/usr/share/emacs/24.2/lisp/term
/home/jcl/elisp/elpa/emms-20121219.1939/tq hides /home/jcl/usr/share/emacs/24.2/lisp/emacs-lisp/tq

Features:
(shadow emacsbug smerge-mode gnus-fun vc-bzr man tabify w3m-form
w3m-lnum w3m-bookmark w3m-tabmenu w3m-session cl-specs edebug
jcl-wesnoth-init wesnoth-mode wesnoth-wml-data wesnoth-update
emms-bookmarks emms-lastfm-client emms-cue emms-mode-line-icon
emms-browser emms-playlist-sort emms-last-played emms-player-xine
emms-player-mpd emms-lyrics emms-url emms-streams emms-tag-editor
emms-info-metaflac emms-mark emms-playlist-limit emms-volume
emms-volume-amixer emms-i18n emms-history emms-score emms-stream-info
emms-metaplaylist-mode elp nnrss xml mm-url tramp-cache mailalias
hippie-exp dabbrev gnus-dired url-cache url-http url-gw url-auth
haskell-mode jcl-w3m w3m-search jcl-work-buffer jcl-games
jcl-text-translator-init text-translator text-translator-window
text-translator-vars text-translator-sites jcl-muse htmlize-hack htmlize
muse-latex muse-html muse-xml-common muse-colors cus-edit cus-start
cus-load muse-publish muse-project muse-protocols muse-regexps muse
muse-nested-tags muse-mode jcl-dictem-init dictem jcl-yaoddmuse
yaoddmuse-extension w3m doc-view jka-compr image-mode timezone w3m-hist
w3m-fb bookmark-w3m w3m-ems w3m-ccl ccl w3m-favicon w3m-image w3m-proc
w3m-util yaoddmuse url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-util url-parse url-vars sgml-mode find-lisp
flow-fill sort smiley gnus-cite mail-extr gnus-bcklg flymake gnus-async
skeleton misearch multi-isearch add-log vc-git scheme org-indent
image-file org-wl org-w3m org-vm org-rmail org-mhe org-mew org-irc
org-jsinfo org-infojs org-html org-info org-gnus org-docview org-bibtex
bibtex org-bbdb jcl-renegade-goblin jcl-home-boot eldoc jcl-status
autorevert network-stream tls jcl-stumpwm jcl-slime slime-fancy
slime-fontifying-fu slime-package-fu slime-references slime-scratch
slime-presentations slime-fuzzy slime-fancy-inspector slime-c-p-c
slime-editing-commands slime-autodoc slime-parse slime-repl slime
derived hyperspec browse-url mule-util flyspell qp parse-time gnus-ml
nndraft nnmh nnfolder nnml gnus-agent gnus-srvr gnus-score score-mode
nnvirtual gnus-msg gnus-art mm-uu mml2015 epg-config mm-view mml-smime
smime dig nntp gnus-cache jcl-gnus-init jcl-gnus gnus-sum nnoo
gnus-group gnus-undo nnmail mail-source gnus-start gnus-spec gnus-int
gnus-range gnus-win mailcap starttls smtpmail sendmail message rfc822
mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047
rfc2045 ietf-drums mailabbrev gmm-utils mailheader gnus gnus-ems
nnheader mail-utils wid-edit jcl-goblin fuzzy-match jcl-load-beta
jcl-torrent text-translator-load jcl-calendar-init appt jcl-calendar
holidays hol-loaddefs diary-lib diary-loaddefs jcl-emms-init
emms-playing-time emms-mode-line emms-cache emms-info-ogginfo
emms-info-mp3info emms-info later-do emms-playlist-mode emms-player-vlc
emms-player-mplayer emms-player-simple emms-source-playlist
emms-source-file locate emms-setup emms emms-compat jcl-org-init
org-latex org-export-latex org-beamer org-exp ob-exp org-exp-blocks
org-agenda footnote 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 org-list
org-faces org-compat org-entities org-macs cal-menu calendar
cal-loaddefs jcl-erc-init jcl-file-cache-init jcl-grep-sbg sbg
jcl-ido-init jcl-dired dired-x dired-details wdired dired-aux
jcl-register-init jcl-command-subset-init jcl-generic generic-x
jcl-erlang-init jcl-ssit jcl-sbg jcl-erlang-log bookmark pp jcl-eel
bindat jcl-sbg-ssit erlang-eunit jcl-erlang distel-ie edb patmatch
erl-service derl erlext epmd net-fsm erl distel erlang etags tempo
jcl-safe jcl-abbrev-init jcl-swedish-postfix quail help-mode jcl-ediff
ediff-merg ediff-diff ediff-wind ediff-help ediff-util ediff-mult
ediff-init ediff jcl-term time-stamp ange-ftp jcl-face hl-line
jcl-modes-init jcl-rfc rfcview view goto-addr proced table picture
noutline outline inf-ruby edmacro ruby-mode sh-script hideshow cwarn
jcl-imenu jcl-global-init which-func imenu time winner thingatpt paren
mic-paren printing ps-print ps-def lpr icomplete ispell uniquify
mb-depth midnight whitespace ffap saveplace dired-details-autoloads
eimp-autoloads emms-autoloads erlang-autoloads fuzzy-match-autoloads
haskell-mode-autoloads htmlize-autoloads inf-ruby-autoloads
lua-mode-autoloads mediawiki-autoloads mic-paren-autoloads
muse-autoloads nrepl-autoloads clojure-mode-autoloads slime-autoloads
tabbar-autoloads w3m-autoloads yaoddmuse-autoloads package
tabulated-list jcl-keys-init diff-mode easy-mmode term disp-table ehelp
kmacro tramp tramp-compat auth-source eieio assoc gnus-util mm-util
mail-prsvr password-cache shell pcomplete format-spec tramp-loaddefs
windmove jcl-keys jcl-load-functions jcl-file-cache ert find-func ewoc
debug filecache jcl-elisp byte-opt warnings bytecomp byte-compile cconv
macroexp hi-lock jcl-register jcl-grep grep compile jcl-command-subset
ido jcl-emacsclient jcl-duff jcl-template-init jcl-template jcl-motion
jcl-windows jcl-misc newcomment jcl-compile jcl-recommended
jcl-site-start fpl electric cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs jpt-mode erlang-start
clearcase tq reporter executable dired comint regexp-opt ansi-color ring
info easymenu jcl-times-init advice help-fns advice-preload jcl-times
jcl-util server jcl-load-path cl time-date 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
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 loaddefs button faces cus-face files text-properties overlay
sha1 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)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes
  2013-01-03 20:31 bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes Johan Claesson
@ 2013-01-04  9:44 ` Andreas Schwab
  2013-10-26 11:42 ` bug#13350: I have same issue in Emacs 24.3.1 (error in process filter: cd: No such directory found via CDPATH environment variable) Oleksandr Gavenko
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2013-01-04  9:44 UTC (permalink / raw)
  To: Johan Claesson; +Cc: 13350

Johan Claesson <johanclaesson@bredband.net> writes:

> I don't know if this buffer size of 4096 varies from system to system.

Presumably that is PIPE_BUF.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13350: I have same issue in Emacs 24.3.1 (error in process filter: cd: No such directory found via CDPATH environment variable)
  2013-01-03 20:31 bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes Johan Claesson
  2013-01-04  9:44 ` Andreas Schwab
@ 2013-10-26 11:42 ` Oleksandr Gavenko
  2013-10-26 14:14   ` Johan Claesson
  2016-01-29 22:41 ` bug#13350: Ran into this term.el bug Jiangbin Zhao
  2016-12-29  2:20 ` bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes npostavs
  3 siblings, 1 reply; 7+ messages in thread
From: Oleksandr Gavenko @ 2013-10-26 11:42 UTC (permalink / raw)
  To: 13350, Johan Claesson, Andreas Schwab

I get:

  error in process filter: cd: No such directory found via CDPATH environment variable
  error in process filter: No such directory found via CDPATH environment variable

when in "M-x term" run:

  ldd `which emacs`

*Backtrace* shown:

Debugger entered--Lisp error: (error "No such directory found via CDPATH environment variable")
  signal(error ("No such directory found via CDPATH environment variable"))
  error("No such directory found via CDPATH environment variable")
  cd("/home/user/devel/my-deve") #[(string) "\b\306\232\203\b.\307\207\b\310H\311U\2031.\312\313\b\314#.\312\313\b	T#.\b\314	O.\315\b	T\nO!.\v\fB\211.,\207\b\310H\316U\203@.\317\b\314\320O!\207\307\207" [string first-colon second-colon filename fileline term-pending-frame "" t 0 26 string-match ":" 1 string-to-number 47 cd nil] 4]("//home/user/devel/my-deve")  term-emulate-terminal(#<process terminal> "6_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f01a9ba5000).\n --==XXXXXXX==--	libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f01a1589000).\n.//home/user/devel/my-deve")

I drop about 4KiB of ldd output at --==XXXXXXX==-- point.

Original example with:

  printf '%4090s' x

and

 printf '%40000s' x

work without problem.

Links:

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13350
                24.2; term.el is confused when bash prints almost 4096 bytes
  http://lists.gnu.org/archive/html/bug-gnu-emacs/2006-10/msg00036.html
                CDPATH problem reappears when using octave-2.9.9 from Emacs 23

-- 
Best regards!





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13350: I have same issue in Emacs 24.3.1 (error in process filter: cd: No such directory found via CDPATH environment variable)
  2013-10-26 11:42 ` bug#13350: I have same issue in Emacs 24.3.1 (error in process filter: cd: No such directory found via CDPATH environment variable) Oleksandr Gavenko
@ 2013-10-26 14:14   ` Johan Claesson
  0 siblings, 0 replies; 7+ messages in thread
From: Johan Claesson @ 2013-10-26 14:14 UTC (permalink / raw)
  To: Oleksandr Gavenko; +Cc: 13350, Andreas Schwab

[-- Attachment #1: Type: text/plain, Size: 853 bytes --]



Hi Oleksandr,

This error is also depending on the current directory.  Or actually just
how long the current $PWD is.  

If you go to /tmp then printf '%4090s' x should trigger the error. 

I think this error is triggered when the commands output is less than
4096 but the sum of the commands output plus the size of current $PWD is
above 4096. (Or N*4096).  Bash appends the $PWD to the commands output
to tell term.el the current directory.  This is made invisible by
term.el.  On the way from the shell to term.el there seem to be
something that splits stuff that is greater than 4096 into fragments.
And term.el do not currently handle when the $PWD is split across two
fragments.

Attached is term-fix.el which contains the term-emulate-terminal
function with the patch applied.  If you evaluate that the error should
go away.

Regards,

/Johan


[-- Attachment #2: term-fix.el --]
[-- Type: application/emacs-lisp, Size: 21631 bytes --]

[-- Attachment #3: Type: text/plain, Size: 1616 bytes --]






Oleksandr Gavenko <gavenkoa@gmail.com> writes:

> I get:
>
>   error in process filter: cd: No such directory found via CDPATH environment variable
>   error in process filter: No such directory found via CDPATH environment variable
>
> when in "M-x term" run:
>
>   ldd `which emacs`
>
> *Backtrace* shown:
>
> Debugger entered--Lisp error: (error "No such directory found via CDPATH environment variable")
>   signal(error ("No such directory found via CDPATH environment variable"))
>   error("No such directory found via CDPATH environment variable")
>   cd("/home/user/devel/my-deve") #[(string) "\b\306\232\203\b.\307\207\b\310H\311U\2031.\312\313\b\314#.\312\313\b	T#.\b\314	O.\315\b	T\nO!.\v\fB\211.,\207\b\310H\316U\203@.\317\b\314\320O!\207\307\207" [string first-colon second-colon filename fileline term-pending-frame "" t 0 26 string-match ":" 1 string-to-number 47 cd nil] 4]("//home/user/devel/my-deve")  term-emulate-terminal(#<process terminal> "6_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007f01a9ba5000).\n --==XXXXXXX==--	libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f01a1589000).\n.//home/user/devel/my-deve")
>
> I drop about 4KiB of ldd output at --==XXXXXXX==-- point.
>
> Original example with:
>
>   printf '%4090s' x
>
> and
>
>  printf '%40000s' x
>
> work without problem.
>
> Links:
>
>   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13350
>                 24.2; term.el is confused when bash prints almost 4096 bytes
>   http://lists.gnu.org/archive/html/bug-gnu-emacs/2006-10/msg00036.html
>                 CDPATH problem reappears when using octave-2.9.9 from Emacs 23

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13350: Ran into this term.el bug
  2013-01-03 20:31 bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes Johan Claesson
  2013-01-04  9:44 ` Andreas Schwab
  2013-10-26 11:42 ` bug#13350: I have same issue in Emacs 24.3.1 (error in process filter: cd: No such directory found via CDPATH environment variable) Oleksandr Gavenko
@ 2016-01-29 22:41 ` Jiangbin Zhao
  2016-12-29  2:20 ` bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes npostavs
  3 siblings, 0 replies; 7+ messages in thread
From: Jiangbin Zhao @ 2016-01-29 22:41 UTC (permalink / raw)
  To: 13350

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

In Emacs version 24.5.3.

The error went away after applying the fix by Johan Claesson.

It seems that term.el has changed since this bug was first reported two
years ago. Is there a reason that Johan's patch isn't accepted?

By the looking, this bug can bite term.el users at random time. It would be
great to have it fixed in the mainline sooner.

Regards,
Jiangbin

[-- Attachment #2: Type: text/html, Size: 504 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes
  2013-01-03 20:31 bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes Johan Claesson
                   ` (2 preceding siblings ...)
  2016-01-29 22:41 ` bug#13350: Ran into this term.el bug Jiangbin Zhao
@ 2016-12-29  2:20 ` npostavs
  2017-01-05  4:26   ` npostavs
  3 siblings, 1 reply; 7+ messages in thread
From: npostavs @ 2016-12-29  2:20 UTC (permalink / raw)
  To: Johan Claesson; +Cc: 13350

[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]

tags 13350 patch
quit

Johan Claesson <johanclaesson@bredband.net> writes:

> emacs -Q
> M-x ansi-term
> /bin/bash
> cd /tmp
> printf '%4090s' x
>
> On my system this gives the error message:
>
> error in process filter: No such directory found via CDPATH environment variable
>
> I think the following is happening:
>
> - Bash will after each command send ?\032 and the current directory
>   "/tmp" to inform term.el. 
> - Bash output is buffered in 4096 bytes chunks.  The end of the first
>   chunk will be "/tm"
> - term.el interprets "/tm" as the current directory and tries to cd
>   there.  Since /tm does not exist it signals an error.
>

Yes, by doing M-x trace-function RET term-emulate-terminal RET, it's
easy to see the chunking.

> I don't know if this buffer size of 4096 varies from system to system.
> In that case maybe the above recipe will not trigger the error on all
> systems. 
>

I needed to use printf '%4088s' x, not sure why the difference.
 
> The following term.el patch is an attempt to fix this:

Patch looks good.  I will push to master in a week or so, unless there
are objections (I added a commit message, see attached).


[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1432 bytes --]

From 6660c98d36dbe39e12906a6d02f1faff22c95590 Mon Sep 17 00:00:00 2001
From: Johan Claesson <johanclaesson@bredband.net>
Date: Wed, 28 Dec 2016 12:56:11 -0500
Subject: [PATCH v1] Fix term.el handling of ^Z-sequences spanning chunks

Bash will after each command send ?\032 and the current directory "/tmp"
to inform term.el.  Bash output is buffered in 4096 bytes chunks.  If a
command outputs roughly 4096 bytes then the end of the first chunk will
be "/tm" (Bug#13350).

* lisp/term.el (term-emulate-terminal): Change the regexp to find the
end of the ?\032 sequence to use \n instead of $, the latter can match
end of string as well.

Copyright-paperwork-exempt: yes
---
 lisp/term.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/term.el b/lisp/term.el
index a4c652b..d3d6390 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -2880,12 +2880,12 @@ term-emulate-terminal
 			  (beep t))
 			 ((and (eq char ?\032)
                                (not handled-ansi-message))
-			  (let ((end (string-match "\r?$" str i)))
+			  (let ((end (string-match "\r?\n" str i)))
 			    (if end
 				(funcall term-command-hook
 					 (decode-coding-string
 					  (prog1 (substring str (1+ i) end)
-					    (setq i (match-end 0)))
+					    (setq i (1- (match-end 0))))
 					  locale-coding-system))
 			      (setq term-terminal-parameter (substring str i))
 			      (setq term-terminal-state 4)
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes
  2016-12-29  2:20 ` bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes npostavs
@ 2017-01-05  4:26   ` npostavs
  0 siblings, 0 replies; 7+ messages in thread
From: npostavs @ 2017-01-05  4:26 UTC (permalink / raw)
  To: Johan Claesson; +Cc: 13350

tags 13350 fixed
close 13350 26.1
quit

npostavs@users.sourceforge.net writes:

> Patch looks good.  I will push to master in a week or so, unless there
> are objections (I added a commit message, see attached).

Pushed as d88cdad28477.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-05  4:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-03 20:31 bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes Johan Claesson
2013-01-04  9:44 ` Andreas Schwab
2013-10-26 11:42 ` bug#13350: I have same issue in Emacs 24.3.1 (error in process filter: cd: No such directory found via CDPATH environment variable) Oleksandr Gavenko
2013-10-26 14:14   ` Johan Claesson
2016-01-29 22:41 ` bug#13350: Ran into this term.el bug Jiangbin Zhao
2016-12-29  2:20 ` bug#13350: 24.2; term.el is confused when bash prints almost 4096 bytes npostavs
2017-01-05  4:26   ` npostavs

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).