[pacman-dev] [PATCH 7/9] repo-add: avoid using ls to check for presence of files

Dan McGee dpmcgee at gmail.com
Fri Jun 24 12:52:09 EDT 2011


On Wed, Jun 22, 2011 at 7:38 PM, Dave Reisner <d at falconindy.com> wrote:
> Signed-off-by: Dave Reisner <d at falconindy.com>
> ---
>  scripts/repo-add.sh.in |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
> index 029e17d..e75055f 100644
> --- a/scripts/repo-add.sh.in
> +++ b/scripts/repo-add.sh.in
> @@ -593,7 +593,7 @@ if (( success )); then
>        filename=${REPO_DB_FILE##*/}
>
>        pushd "$tmpdir" >/dev/null
> -       if [[ -n $(ls) ]]; then
> +       if ( shopt -s nullglob; files=(*); (( ${#files[*]} )) ); then
>                bsdtar -c${TAR_OPT}f "$filename" *
>        else
>                # we have no packages remaining? zip up some emptyness

Let's take a step back and just kill the entire conditional:

bsdtar -c${TAR_OPT}f "$filename" -s /^.\// .

"Add the current directory, but we don't want the ./ bits on the added paths."


More information about the pacman-dev mailing list