bug-bash
[Top][All Lists]
Advanced

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

Re: AW: Questions to bash "read" builtin functionality


From: Chet Ramey
Subject: Re: AW: Questions to bash "read" builtin functionality
Date: Wed, 19 Dec 2012 16:49:32 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 12/17/12 3:34 AM, Fiedler Roman wrote:

> From your description, I would expect 
> 
> --- HYPOTHETICAL-OUTPUT---
> # ./FragmentedSend.py | ./BashReadTest 
> Read status 142, value ""
> Read status 142, value "Stat"      << the partial read
> FAILED READ: "us: OK"
> Traceback (most recent call last):
>   File "./FragmentedSend.py", line 16, in <module>
>     os.write(1, nextSendData[0:sendLength])
> OSError: [Errno 32] Broken pipe
> --- HYPOTHETICAL-OUTPUT---
> 
> Is this consistent with what you would be expecting!

I get the following with a few runs of the above code against a freshly-
built bash-4.2.39 (x24 is just a script that wraps the pipeline):

$ ./bash ./x24
Read status 142, value ""
Read status 142, value "Status:"
Read status 142, value ""
FAILED READ: "OK"
Traceback (most recent call last):
  File "./FragmentedSend.py", line 16, in <module>
    os.write(1, nextSendData[0:sendLength])
OSError: [Errno 32] Broken pipe
$ ./bash ./x24
Read status 142, value ""
Read status 142, value "Statu"
Read status 142, value "s:"
FAILED READ: "OK"
Traceback (most recent call last):
  File "./FragmentedSend.py", line 16, in <module>
    os.write(1, nextSendData[0:sendLength])
OSError: [Errno 32] Broken pipe
$ ./bash ./x24
Read status 142, value ""
Read status 142, value "Status: OK"
FAILED READ: ""
Traceback (most recent call last):
  File "./FragmentedSend.py", line 16, in <module>
    os.write(1, nextSendData[0:sendLength])
OSError: [Errno 32] Broken pipe
$ ./bash ./x24
Read status 142, value "Sta"
Read status 142, value "tus: O"
FAILED READ: "K"
Traceback (most recent call last):
  File "./FragmentedSend.py", line 16, in <module>
    os.write(1, nextSendData[0:sendLength])
OSError: [Errno 32] Broken pipe

I get the same results if I run the pipeline in an interactive shell.
This is pretty much what I expect.  The whitespace and newlines will
disappear due to read's $IFS processing if they're first or last in
the string.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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