public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Ulrich Mueller <ulm@gentoo.org>
To: "Maciej Barć" <xgqt@gentoo.org>
Cc: gentoo-dev@lists.gentoo.org,  ml@gentoo.org
Subject: Re: [gentoo-dev] [PATCH v3] eclass/dune.eclass: fix dune-install function
Date: Fri, 10 Dec 2021 07:54:20 +0100	[thread overview]
Message-ID: <ufsr1j6g3@gentoo.org> (raw)
In-Reply-To: <20211209223635.22369-1-xgqt@gentoo.org> ("Maciej Barć"'s message of "Thu, 9 Dec 2021 23:36:35 +0100")

[-- Attachment #1: Type: text/plain, Size: 1196 bytes --]

>>>>> On Thu, 09 Dec 2021, Maciej Barć wrote:

>  dune-install() {
> +	local pkgs
> +	if [[ -n "${@}" ]] ; then
> +		pkgs="${@}"

Here pkgs is a scalar ...

> +	else
> +		pkgs=${DUNE_PKG_NAME}
> +	fi
> +
> +	local myduneopts=(
> +		--prefix="${ED%/}/usr"
> +		--libdir="${D%/}$(ocamlc -where)"
> +		--mandir="${ED%/}/usr/share/man"
> +	)
>  	local pkg
> -	for pkg ; do
> -		dune install \
> -			--prefix="${ED%/}/usr" \
> -			--libdir="${D%/}$(ocamlc -where)" \
> -			--mandir="${ED%/}/usr/share/man" \
> -			"${pkg}" || die
> +	for pkg in ${pkgs[@]} ; do

... and here it's an array?

> +		dune install ${myduneopts[@]} ${pkg} || die
> +
> +		# Move docs to the appropriate place.
> +		if [ -d "${ED%/}/usr/doc/${pkg}" ] ; then
> +			mkdir -p "${ED%/}/usr/share/doc/${PF}/" || die
> +			mv "${ED%/}/usr/doc/${pkg}" "${ED%/}/usr/share/doc/${PF}/" || die
> +			rm -rf "${ED%/}/usr/doc" || die
> +		fi
>  	done
>  }

I'd write something like this:

	local -a pkgs=("$@")
	[[ ${#pkgs[@]} -eq 0 ]] && pkgs=(${DUNE_PKG_NAME})

And the loop like this (note the double quotes to be whitespace-safe):

	for pkg in "${pkgs[@]}"; do
		...
	done

Ulrich

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]

  reply	other threads:[~2021-12-10  6:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 22:36 [gentoo-dev] [PATCH v3] eclass/dune.eclass: fix dune-install function Maciej Barć
2021-12-10  6:54 ` Ulrich Mueller [this message]
2021-12-10  7:53   ` Ulrich Mueller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ufsr1j6g3@gentoo.org \
    --to=ulm@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=ml@gentoo.org \
    --cc=xgqt@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox