This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On 12/13/2012 05:46 AM, Joel Brobecker wrote:

> This is my evil twin :-).

:-)

>> 2012-12-12  Pedro Alves  <palves@redhat.com>
>>
>> 	* gdbarch.sh (do_read): Set IFS to blank.
> 
> Looks good to me.
> 
> Good analysis, as /bin/sh is indeed a link to dash on my laptop.

Thanks for confirming.  I've applied it now, with an added comment.

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

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

---
 gdb/gdbarch.sh |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 887552e..8a56106 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -47,7 +47,10 @@ do_read ()
 {
     comment=""
     class=""
-    while read line
+    # On some SH's, 'read' trims leading and trailing whitespace by
+    # default (e.g., bash), while on others (e.g., dash), it doesn't.
+    # Set IFS to empty to disable the trimming everywhere.
+    while IFS='' read line
     do
 	if test "${line}" = ""
 	then


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]