GNU bug report logs - #8632
23.2; shell-script[bash] doesn't handle bitshift $(( 1 << 16 ))

Previous Next

Package: emacs;

Reported by: Ben Wong <bug-gnu-emacs+gnu.org <at> wongs.net>

Date: Fri, 6 May 2011 23:35:01 UTC

Severity: normal

Merged with 15941

Found in versions 23.2, 24.2

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8632 in the body.
You can then email your comments to 8632 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8632; Package emacs. (Fri, 06 May 2011 23:35:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ben Wong <bug-gnu-emacs+gnu.org <at> wongs.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 06 May 2011 23:35:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ben Wong <bug-gnu-emacs+gnu.org <at> wongs.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2; shell-script[bash] doesn't handle bitshift $(( 1 << 16 ))
Date: Fri, 06 May 2011 15:38:05 -0700
In shell-script mode (bash minor mode) Emacs 23.2 incorrectly parses the
following line as a HERE DOCUMENT.

	echo $(( 1 << 16 ))

It is confused because sh-font-lock-open-heredoc (in sh-script.el)
does not know about bash's ARITHMETIC EXPANSION. There should be a
function, similar to sh-in-comment-or-string, which parses the
script looking for arithmetic expansion.

As a temporary workaround for users, I believe it is legal to put double
quotes around any arithmetic expansion to force emacs to view it as a
string.


In GNU Emacs 23.2.1 (i486-pc-linux-gnu, GTK+ Version 2.20.0)
 of 2010-12-11 on raven, modified by Debian
configured using `configure  '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.2/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.2/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.2/leim' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g -O2' 'LDFLAGS=-g' 'CPPFLAGS=''

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: Shell-script

Minor modes in effect:
  shell-dirtrack-mode: t
  gpm-mouse-mode: t
  which-function-mode: t
  show-paren-mode: t
  display-time-mode: t
  recentf-mode: t
  iswitchb-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  line-number-mode: t





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8632; Package emacs. (Fri, 13 May 2011 19:14:02 GMT) Full text and rfc822 format available.

Message #8 received at 8632 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Ben Wong <bug-gnu-emacs+gnu.org <at> wongs.net>
Cc: 8632 <at> debbugs.gnu.org
Subject: Re: bug#8632: 23.2;
	shell-script[bash] doesn't handle bitshift $(( 1 << 16 ))
Date: Fri, 13 May 2011 16:12:54 -0300
> In shell-script mode (bash minor mode) Emacs 23.2 incorrectly parses the
> following line as a HERE DOCUMENT.

> 	echo $(( 1 << 16 ))

> It is confused because sh-font-lock-open-heredoc (in sh-script.el)
> does not know about bash's ARITHMETIC EXPANSION.

Indeed, thanks for spotting this.

> There should be a function, similar to sh-in-comment-or-string, which
> parses the script looking for arithmetic expansion.

I guess the way to do it would be to try to handle $(( as
a string-opener in sh-syntax-propertize-function and then write
code to jump to the matching )) to mark it as the string-closer.

Patch welcome,


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#8632; Package emacs. (Tue, 17 Apr 2012 10:29:01 GMT) Full text and rfc822 format available.

Message #11 received at 8632 <at> debbugs.gnu.org (full text, mbox):

From: Vincent Lefevre <vincent <at> vinc17.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Ben Wong <bug-gnu-emacs+gnu.org <at> wongs.net>, 8632 <at> debbugs.gnu.org
Subject: Re: bug#8632: 23.2; shell-script[bash] doesn't handle bitshift $(( 1
	<< 16 ))
Date: Tue, 17 Apr 2012 12:28:31 +0200
On 2011-05-13 16:12:54 -0300, Stefan Monnier wrote:
> > In shell-script mode (bash minor mode) Emacs 23.2 incorrectly parses the
> > following line as a HERE DOCUMENT.
> 
> > 	echo $(( 1 << 16 ))
> 
> > It is confused because sh-font-lock-open-heredoc (in sh-script.el)
> > does not know about bash's ARITHMETIC EXPANSION.
> 
> Indeed, thanks for spotting this.

Actually this is a much more general problem. See

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11263

-- 
Vincent Lefèvre <vincent <at> vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Merged 8632 15941. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 20 Nov 2013 22:16:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 19 Dec 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 185 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.