bug-bash
[Top][All Lists]
Advanced

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

Re: read fails on null-byte: v4.1.7 FreeBSD 8.0 (amd64)


From: Matthew Story
Subject: Re: read fails on null-byte: v4.1.7 FreeBSD 8.0 (amd64)
Date: Tue, 29 Nov 2011 11:43:08 -0500

Re-sending in text form instead of attached gzip ... as this seems to be the 
prevailing style on list ... this patch discards null-bytes in the read builtin 
along with documentation of existing -d '' behavior and expected discard 
behavior without for both the man and info.

(run with patch -p1)

commit df4bdef6d6066beeac57cf36f54cff7bde8f5ea3
Author: Matthew Story <matt@tablethotels.com>
Date:   Mon Nov 28 22:51:59 2011 -0500

    Update documentation (both man and info) to reflect read NUL character
    behavior, and -d ''. 
    
    Signed-off-by: Matthew Story <matt@tablethotels.com>

diff --git a/doc/bash.1 b/doc/bash.1
index 0ba4f8e..ef3f174 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -8284,6 +8284,8 @@ The characters in
 are used to split the line into words.
 The backslash character (\fB\e\fP) may be used to remove any special
 meaning for the next character read and for line continuation.
+Unless '' (an empty string) is supplied as an argument to the 
+\fB\-d\fP option, NUL characters are stripped from input.  
 Options, if supplied, have the following meanings:
 .RS 
 .PD 0
@@ -8299,7 +8301,7 @@ Other \fIname\fP arguments are ignored.
 .TP 
 .B \-d \fIdelim\fP
 The first character of \fIdelim\fP is used to terminate the input line,
-rather than newline.
+rather than newline. If '' (an empty string) is suppilied as \fIdelim\fP, NUL 
characters are used to terminate the input line.
 .TP
 .B \-e
 If the standard input
diff --git a/doc/bashref.texi b/doc/bashref.texi
index b4fd8d3..36f61d3 100644
--- a/doc/bashref.texi
+++ b/doc/bashref.texi
@@ -3890,6 +3890,8 @@ variable @env{REPLY}.
 The return code is zero, unless end-of-file is encountered, @code{read}
 times out (in which case the return code is greater than 128), or an
 invalid file descriptor is supplied as the argument to @option{-u}.
+Unless '' (an empty string) is supplied as an argument to 
+@option{-d}, NUL characters are stripped from input.

 Options, if supplied, have the following meanings:

@@ -3902,7 +3904,8 @@ Other @var{name} arguments are ignored.

 @item -d @var{delim}
 The first character of @var{delim} is used to terminate the input line,
-rather than newline.
+rather than newline. If '' (an empty string) is suppilied as @var{delim},
+NUL characters are used to terminate the input line.

 @item -e
 Readline (@pxref{Command Line Editing}) is used to obtain the line.

commit 7b9ce5228c6483729d7823c853c9eadcc7721fb3
Author: Matthew Story <matt@tablethotels.com>
Date:   Mon Nov 28 22:50:33 2011 -0500

    Strip null-bytes from read when DELIM is not `'.

    Preserves what seems to be used behavior in read -d '' (split on
    NUL character)

    Signed-off-by: Matthew Story <matt@tablethotels.com>

diff --git a/builtins/read.def b/builtins/read.def
index 1b87faa..47074bb 100644
--- a/builtins/read.def
+++ b/builtins/read.def
@@ -563,6 +563,8 @@ read_builtin (list)
      saw_escape++;
      input_string[i++] = CTLESC;
    }
+      if (c == '\0')          /* drop literal NUL if delim is not '' */
+   continue;

 add_char:
       input_string[i++] = c;


reply via email to

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