bug-bash
[Top][All Lists]
Advanced

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

Re: unexpected behavior of 'read' builtin


From: Chet Ramey
Subject: Re: unexpected behavior of 'read' builtin
Date: Sat, 24 May 2008 14:33:34 -0400
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

Juliano F. Ravasi wrote:

    I got bitten by two unexpected (and undocumented) behaviors of
    the 'read' builtin.

    The first one is that it doesn't seem to handle word separators
    equally, making distinction when spaces and non-space
    separators are used to separate words.

Posix makes the distinction explicit.  Read the `Field Splitting'
section (2.6.5) in
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_05


    The second one is that it chops leading and trailing whitespace
    when you provide one variable for assignment, and not when you
    use the default $REPLY.

This is the behavior to which the language in the man page that talks
about `the line read' being assigned to REPLY refers.  Bash behaves as
it does when using REPLY to make it easy to read an entire line verbatim
without having to temporarily alter $IFS.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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