print -rC1 -- $files # print raw, on one column.
(N) qualifier to apply
nullglob to that glob, to that
$files become an empty list of the pattern doesn't match any file instead of reporting an error).
For files other than
set -o extendedglob # needed for the ^ negation operator
For case insensitive matching (
set -o extendedglob
is wrong on several accounts:
FILES="$PWD/*" doesn't store the list of files in the
$FILE variable. That's a scalar assignment, which can only ever store one value. Instead it stores in
$FILES the contents of
$PWD followed by
echo $FILES as
$FILES is not quoted, in
bash (but not
zsh), the expansion of
$FILES is subject to split+glob. And it's at that point, and assuming that
$FILES contains none of the characters of
$IFS (which would trigger the split part), and that
$PWD doesn't contain wildcard characters (that would also trigger the glob part) that the value is expanded to the list of matching files.
zsh, split+glob is not done implicitly upon parameter expansion, you need to request them explicitly (
$=FILES for splitting,
$~FILES for globbing,
$=~FILES for both).
echo to output arbitrary data is wrong as
echo does extra processing by default (in
zsh, you could use
echo -E - $files or
print -r -- $files though).