4     # Desc: Filters stdin lines for paths with basenames that are not dotfiles 
   5     # Usage: printf "foo\n" | filter_no_dots [path] 
   6     # Input: stdin (consumes) 
   8     # Output: stdout (only outputs lines if basename is not a dotfile) 
  10     # Depends: GNU bash (v5.1.16) 
  12     local input_stdin input_psarg buffer re output
; 
  15     if [[ -p /dev
/stdin 
]]; then 
  16         input_stdin
="$(cat -)"; 
  20     if [[ $# -gt 0 ]]; then 
  24     # Combine as buffer array elements 
  26     if [[ -n $input_stdin ]]; then 
  27         while read -r line
; do 
  29         done < <(printf "%s\n" "$input_stdin"); 
  31     ## Read in positional arguments 
  32     if [[ -n $input_psarg ]]; then 
  39     re
="^\."; # first char is a dot 
  40     while read -r line
; do 
  42         file_name
="$(basename "$line")"; 
  43         # Add path to output if basename not a dotfile 
  44         if [[ ! "$file_name" =~ 
$re ]]; then 
  49     done < <( printf "%s\n" "${buffer[@]}" ); 
  51     # Print output array to stdout 
  52     printf "%s\n" "${output[@]}"; 
  53 }; # Filters stdin lines for paths with basenames that are not dotfiles 
  56 printf "foo\n.bar\nbaz\n" | filter_no_dots 
"$HOME/.local" "$HOME/"