bug-bash
[Top][All Lists]
Advanced

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

Re: read builtin function keeps trailing white space


From: Jan Schampera
Subject: Re: read builtin function keeps trailing white space
Date: Thu, 10 Apr 2008 06:53:50 +0200
User-agent: IceDove 1.5.0.14pre (X11/20080305)

Eduardo Sanz Garcia wrote:

> 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).

This behaviour is IMHO intended and documented. Using one or more
variable name(s) makes read assigning "every word" to the variable(s);
using no variable name (fallback to REPLY) makes it assigning "the line"
(!) to REPLY. It's a bit hidden in documentation, you need to see the
difference between "words" and "line" in manpage.

J.







reply via email to

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