I'm trying to create an array of file names, based on two variable and using brace expansion, like this:
#!/bin/bash
altdir=/usr
arg=abc
tries=({.,$altdir}/{$arg,$arg/main}.{tex,ltx,drv,dtx})
for i in "${tries[@]}"; do echo $i; done
The last statement list the files I want correctly:
./abc.tex
./abc.ltx
./abc.drv
./abc.dtx
./abc/main.tex
./abc/main.ltx
./abc/main.drv
./abc/main.dtx
/usr/abc.tex
/usr/abc.ltx
/usr/abc.drv
/usr/abc.dtx
/usr/abc/main.tex
/usr/abc/main.ltx
/usr/abc/main.drv
/usr/abc/main.dtx
But shellcheck tells me that the two variables, altdir and arg, appear to be unused:
$ shellcheck testscript
In testscript line 3:
altdir=/usr
^-- SC2034: altdir appears unused. Verify it or export it.
In testscript line 4:
arg=abc
^-- SC2034: arg appears unused. Verify it or export it.
Is there a better way to do this?