bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read builtin function keeps trailing white space


From: Eduardo Sanz Garcia
Subject: read builtin function keeps trailing white space
Date: Wed, 09 Apr 2008 17:35:46 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080201 SeaMonkey/1.1.8

*Configuration Information* [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-redhat-linux-gnu' -DCONF_VENDOR='redhat' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 uname output: Linux bighorn 2.6.9-67.0.4.ELsmp #1 SMP Sun Feb 3 07:08:57 EST 2008 i686 i686 i386 GNU/Linux
Machine Type: i686-redhat-linux-gnu

Bash Version: 3.0
Patch Level: 15
Release Status: release
*
Description:*
read builtin function keeps trailing white space when the default variable REPLY is used. This is specially bad when using the -e option because readline puts and extra space after pressing a the tab key to autocomplete a word.
   The IFS that delimits a word shouldn't be assigned to the variable.
*
Repeat-By:*
   Type the following:
   read
   type something with one trailing space
   echo "|$REPLY|"
   REPLY keeps the trailing white space

   Then try this other variant:
   read VAR
   type something with one trailing space
   echo "|$VAR|"
   VAR doesn't keep the trailing white space.
This last behavior is the correct because "read" should parse everything by words (IFS are the delimiters and are not included).

*Additional comments:*
This behavior cases problems, for example, if you then try to check the existence of a file:
       if [ -e "$REPLY" ]; then
fails because of the trailing white space. The quotes are necessary to check for null.

*Fix:*
   None

Thank you very much.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]