Re: [PATCH 2/4] base-files/functions.sh: do not iterate over ls

2020-09-25 Thread Rosen Penev
On Sun, Sep 20, 2020 at 3:15 AM wrote: > > On 20.09.2020 07:31, Rosen Penev wrote: > > - for file in $(ls $1/*.sh 2>/dev/null); do > > - . $file > > + for file in "$1"/*.sh; do > > + [ -e "$file" ] || break > > + . "$file" > > the existence check is

Re: [PATCH 2/4] base-files/functions.sh: do not iterate over ls

2020-09-20 Thread edgar . soldin
On 20.09.2020 07:31, Rosen Penev wrote: > - for file in $(ls $1/*.sh 2>/dev/null); do > - . $file > + for file in "$1"/*.sh; do > + [ -e "$file" ] || break > + . "$file" the existence check is probably meant to catch "../*.sh" entry found if no files

[PATCH 2/4] base-files/functions.sh: do not iterate over ls

2020-09-19 Thread Rosen Penev
>From https://github.com/koalaman/shellcheck/wiki/SC2045 : When looping over a set of files, it's always better to use globs when possible. Using command expansion causes word splitting and glob expansion, which will cause problems for certain filenames (typically first seen when trying to