Can somebody tell me what am I doing wrong in following shell function?
NOTES_PATH="/home/temp"
function open_note {
    local files=()                                                          
    while IFS=  read -r -d $'\0' filename; do                                        
        files+=("$filename")                                                   
    done < <(find "$NOTES_PATH" -maxdepth 1 -type f -print0 | xargs -0 ls -t)
    echo "There is/are ${#files[@]} file(s) available"
}
I get "There is/are 0 file(s) available" everytime even though I can see 2 text files in /home/temp directory.
Please note that I want to use while loop approach to read filenames, not any other way unless I cannot achieve what I want to do. [credits: John1024 answer]
P.S. If I run find /home/temp -maxdepth 1 -type f -print0 | xargs -0 ls -t from command line, I get expected result.
 
     
    