From: carl To: bug-bash@gnu.org Subject: [50 character or so descriptive subject here (for reference)] In a script two instances of the read builtin mutually interfere Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer uname output: Linux md-tower-004 6.5.12-300.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Nov 20 22:44:24 UTC 2023 x86_64 GNU/Linux Machine Type: x86_64-redhat-linux-gnu
Bash Version: 5.2 Patch Level: 21 Release Status: release Description: [Detailed description of the problem, suggestion, or complaint.] I have a script to go through file names in the current directory, check whether they contain blanks and optionally replace blanks with underscores. The first step in the main program is:- ls -l >/tmp/$USER/tempfile1 Then follows a while read REPLY; do # loop to read records from /tmp/$USER/tempfile1 # The first record is discarded, from the remainder the File_Name is extracted and passed to a functionas a quoted string to function File_Contains_Blanks "$File_Name" # Global variable GRV_File_Contains_Blanks returns true if there is at least one blank # Function Get_Reply is called to get a Y or N answer preceded by a prompt using the read command # Instead of this happening the read command in Get_Reply goes into an infinite loop reading remaining # records in /tmp/$USER/tempfile1 and continuing until terminated by Ctrl - C # obviously some data from the read in command in the main program while read loop is contaminatng that for the read -r -p $1 command in Get_Reply Repeat-By: [Describe the sequence of events that causes the problem to occur.] The first file name containing blanks is encountered the read -r -p $1 command in function Get_Reply is executed Fix: [Description of how to fix the problem. If you don't know a fix for the problem, don't include this section.] I will look for a third party replacement for the read builtin in the function Get_Reply. It is not urgent I was mainly doing it as an exercise to learn bash scripting. My email address is carlyle_moul...@optusnet.com.au. If you want the full text of the script I will send it. ------------------------- Email sent using Optus Webmail