From nobody Fri Nov 11 14:43:32 2022 X-Original-To: freebsd-ports@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N81g53qK8z4dq6B for ; Fri, 11 Nov 2022 14:44:01 +0000 (UTC) (envelope-from 6yearold@gmail.com) Received: from mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N81g50rfJz4F4x; Fri, 11 Nov 2022 14:44:01 +0000 (UTC) (envelope-from 6yearold@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-vs1-f45.google.com with SMTP id q127so5375061vsa.7; Fri, 11 Nov 2022 06:44:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xA4QYPCEQD8oa/F3N3lsST1QCJUUxY29QFhWICxb+Ms=; b=Jv8AtI4TP+xY9q8EmebhHajzGF9NL/f8rnCLcenOx8Ot0ooLC7+ZZnAHUAGbelSTJa Bo6xPrkvfFgAgG+v2btDNTjHNAiMSimIxfPMFxFd4bzdGQwXXIRQ60ys7H8Yb2TxDk5G 6dl/+dkoG+POvPgHYzvvDGqQwpY8KV+kp07finKViD2iCmJgdJIQEQJS9dFvgdwcKtWO 6OBXfwyKRjeOF0W3tV+jAJUc6Yo3gynfVDU3jEVuQlD9o/h6DznFffch0fQRrutCD2cf aPBgv3jOFuOJH+TOeIeE08H9s1qZMMEpaTk7mw21pqnXezxEqa+LInhwbp4c4FT/40yS z/5A== X-Gm-Message-State: ANoB5pk9VvZit9N6osC2XwXDTFdjAWozg0/fA3C49tnrruFTW+wSJVBj WJRy7bk+muo47SOp0VKpAcdaXC4xdxRhNQ== X-Google-Smtp-Source: AA0mqf7ZrrTFwM3i/tW+xPzDGxnH/Ez6p+ptppPPyNnO4aXDFTjdiRNbQwzX9hrF/ALDcd7b2je1og== X-Received: by 2002:a05:6102:22dc:b0:3aa:505a:9522 with SMTP id a28-20020a05610222dc00b003aa505a9522mr851824vsh.56.1668177839481; Fri, 11 Nov 2022 06:43:59 -0800 (PST) Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com. [209.85.217.43]) by smtp.gmail.com with ESMTPSA id s5-20020a1f2c05000000b003a9f2a90f43sm367508vks.29.2022.11.11.06.43.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Nov 2022 06:43:59 -0800 (PST) Received: by mail-vs1-f43.google.com with SMTP id t14so5365042vsr.9; Fri, 11 Nov 2022 06:43:59 -0800 (PST) X-Received: by 2002:a67:e049:0:b0:3a7:a53:537e with SMTP id n9-20020a67e049000000b003a70a53537emr973343vsl.12.1668177838821; Fri, 11 Nov 2022 06:43:58 -0800 (PST) List-Id: Porting software to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-ports List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org MIME-Version: 1.0 References: <20221111145635.045da586@FreeBSD.org> In-Reply-To: <20221111145635.045da586@FreeBSD.org> From: Gleb Popov Date: Fri, 11 Nov 2022 17:43:32 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Temporary variables in make .for loops To: =?UTF-8?Q?T=C4=B3l_Coosemans?= Cc: FreeBSD ports list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 4N81g50rfJz4F4x X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US] X-ThisMailContainsUnwantedMimeParts: N On Fri, Nov 11, 2022 at 4:56 PM T=C4=B3l Coosemans wrote= : > > On Fri, 11 Nov 2022 15:41:51 +0300 Gleb Popov wrote: > > Hello fellow porters. > > > > My variable modifiers are growing and become too incomprehensible, so > > here is the question I wanted to ask long ago: > > > > How do I make and use a temporary variable in the .for loop? > > > > This is what I have in Mk/Uses/cabal.mk: > > > > . for package in ${_use_cabal} > > _PKG_GROUP=3D ${package:C/[\.-]//g} > > > > MASTER_SITES+=3D https://hackage.haskell.org/package/:${package:C/[\= .-]//g} > > . endfor > > > > I'd like to write ${_PKG_GROUP} instead of repeating that regexp > > incantation, but due to specifics of .for operation it doesn't work. > > Using :=3D with _PKG_GROUP also doesn't fix the problem. > > > > Now I need to add another regexp substitution to every expression > > inside this loop and it'll become even less readable than before. > > > > Is there a clean solution to this problem? > > You could use a nested .for loop: > > . for package in ${_use_cabal} > . for pkg_group pkg_norev rev in \ > ${package:C/[.-]//g} ${packa...} ${packa...} > > You can drop the backslash by the way. That's a really neat trick, thanks!