I was trying to improve a function definition using flycheck (shellcheck). The commented line on the code below is what I tried to improve. The code works but I get the error message syntax error near unexpected token
('`
my_loop() {
# for ifastq in $(ls $1 | grep -v txt)
for ifastq in $1/*.f?(ast)q?(.gz)
do
echo "$ifastq"
done
}
Is the code above more fragile than the one using the commented line?
Should I also include shopt -s extglob
in the function definition or at the top of the script?
Thanks
BTW: the code is supposed to capture files with .fastq .fq fq.gz or .fastq.gz extensions