[commit/obv] Remove trailing space in gdbarch.sh.

Pedro Alves palves@redhat.com
Wed Dec 12 15:33:00 GMT 2012


On 12/12/2012 01:56 PM, Joel Brobecker wrote:
> Hello,
> 
> I noticed this trailing space when I ran an unmodified gdbarch.sh,
> and yet got a difference in gdbarch.h!  Fixed in gdbarch.sh.

I don't see such a difference, but the patch is of course fine.

git blame on the corresponding line on gdbarch.h points at:

Author: Joel Brobecker <brobecker@gnat.com>
Date:   Wed Oct 26 21:23:54 2011 +0000

    Regenerate gdbarch.h
    
    Not sure why, but the version currently checked in as an extraneous
    trailing whitespace that showed up as a diff when I reran gdbarch.sh.
    
    gdb/ChangeLog:
    
            * gdbarch.h: Regenerate.

:-)

I'm going to guess that you've been switching between systems, and
on some of those /bin/sh is bash while on others its dash
(most likely the latter is Ubuntu).

Regenerating gdbarch.h from scratch with bash always ends up with
that whitespace stripped for me.  If I run 'dash ./gdbarch.sh'
then indeed I see the extra space ending on up gdbarch.h.

"read" trims leading and trailing whitespace by default (on bash at least).  We
can make it not do that by setting the IFS variable to empty, like in the
patch below.  This should make it so that all shells behave the same
here (tried bash and dash), which I think would be good.

WDYT?

2012-12-12  Pedro Alves  <palves@redhat.com>

	* gdbarch.sh (do_read): Set IFS to blank.
---

 gdb/gdbarch.sh |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 81a70b0..7433378 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -47,7 +47,7 @@ do_read ()
 {
     comment=""
     class=""
-    while read line
+    while IFS='' read line
     do
 	if test "${line}" = ""
 	then



More information about the Gdb-patches mailing list