X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=builtins%2Fread.def;h=64a4a11a4a4723feaec3d89a98be2d45812f9162;hb=d166f048818e10cf3799aa24a174fb22835f1acc;hp=eb04a3061ccbd22612b728aabcf31b0cd0eb7d81;hpb=ccc6cda312fea9f0468ee65b8f368e9653e1380b;p=platform%2Fupstream%2Fbash.git diff --git a/builtins/read.def b/builtins/read.def index eb04a30..64a4a11 100644 --- a/builtins/read.def +++ b/builtins/read.def @@ -164,7 +164,7 @@ read_builtin (list) { if (rlbuf && rlbuf[rlind] == '\0') { - free (rlbuf); + xfree (rlbuf); rlbuf = (char *)0; } if (rlbuf == 0) @@ -247,13 +247,28 @@ read_builtin (list) assign_array_var_from_word_list (var, alist); dispose_words (alist); } - free (input_string); + xfree (input_string); return (retval); } #endif /* ARRAY_VARS */ - if (!list) + /* If there are no variables, save the text of the line read to the + variable $REPLY. ksh93 strips leading and trailing IFS whitespace, + so that `read x ; echo "$x"' and `read ; echo "$REPLY"' behave the + same way, but I believe that the difference in behaviors is useful + enough to not do it. Without the bash behavior, there is no way + to read a line completely without interpretation or modification. + If you disagree, change the occurrences of `#if 0' to `#if 1' below. */ + if (list == 0) { +#if 0 + orig_input_string = input_string; + for (t = input_string; ifs_chars && *ifs_chars && spctabnl(*t) && issep(*t); t++) + ; + input_string = t; + input_string = strip_trailing_ifs_whitespace (input_string, ifs_chars, saw_escape); +#endif + if (saw_escape) { t = dequote_string (input_string); @@ -263,7 +278,11 @@ read_builtin (list) else var = bind_variable ("REPLY", input_string); var->attributes &= ~att_invisible; +#if 0 + free (orig_input_string); +#else free (input_string); +#endif return (retval); }