On Mon, Aug 02, 2021 at 03:40:24PM +0000, hancooper wrote:
> I got into it as am populating an array of files, checking if they exist or
> are redundant.
>
> for file in "$@"; do
> file_redundant=false
$file_redundant contains a string "false". It is NOT a boolean variable.
> for fde in "${flist[@]}"; do
> [[ $fde == $file ]] && file_redundant=true
If you use $file without quotes, it is considered a pattern. To match $fde and
$file as strings, you should quote $file, i.e. [[ "$fde" == "$file" ]].
> done
> [[ (-f "$file") && (! $file_redundant) ]] && flist+=("$file")
(! $file_redundant) is always false here because $file_redundant is initialized
to a string ("false" or "true"). Try ("$file_redundant" == "true") instead.
--
Leonid Isaev