From nobody Fri Nov 11 13:56:35 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 4N80ck3Zbmz4dfpQ for ; Fri, 11 Nov 2022 13:56:54 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N80ck34nXz46br; Fri, 11 Nov 2022 13:56:54 +0000 (UTC) (envelope-from tijl@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668175014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zlCp0mZp9KMXEMMUPbxeOVpsH5eV/x/Ys3b7gbz7v2Q=; b=VewHvYCvHvKrznq193z9mGg1ZFTXpEiTo7wbB+mQyqbwEfF58G+ZFV44eeM48WXhZ+Vz1U rXKeXUUXl9Z+pHKCkg9zOqZyNF0q4MGCd6hUt7GJk+YdQoOaUqjGXdFNpp+4jRTdRrJTrJ Blg3c6UGlQ6eljE8j9Xtven+WPzotUajY50+QmgHF4+gpAOrJrdVj2hHQQOCYE6HYvBB2e dqjv9d2KCn+1KYC2VwQBc4kzZt4FDlY9bmOxERy7LHt2tEG9tmQSn9kl++X867xDfajA9a YELIVvX42QT0LMX0pcMmLuJiv+ycxvUtBwiP0scIMkT0+/ZpJfkOPz7bSlgxTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668175014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zlCp0mZp9KMXEMMUPbxeOVpsH5eV/x/Ys3b7gbz7v2Q=; b=LFLawZg53ZA5Xlisal8T3HJaUge1Oqb6yucjXsOz542s2Qdy0lrSsAVXT/oY24h2Xb5bFg GlhJ9OSSkFWPQ1XDWs0ac1kphcFtBT3MG/rc8stBuxV4Y/1lCz99I0dW+HYJWfrahRrIoD UYsI5eZud/VANPmh78dWAQiu8TbyRBDbndO92Jz6EqGhdSWWS0djDVyTVcGwAOOy35QLji LQOY6GNajK6c5l4RelpNJgoQ9TBDOHHRz6fU5hk60iX50AuK5rclc944WLSDH2MGCV0Kq9 +gqq1cc4FpchokQBBMXAgeGWg5JAYEzauDvWou2ln5ejH3YOsWQwUq3Itzwzgg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668175014; a=rsa-sha256; cv=none; b=LVx3xWjTHUp3Xslw2l3NTCsCpO0LfVZT6rxzMBu8jRczGEiJUySSqssnjpIBT8DjVL3K+j nwDYHnUzuIwU61GgUxggNOu5qdDeBS3QQFwo0IlpVu9Bc0D5i113QPXvm38k0XW13BYxG+ d1+N0Wc7gCuHTowBQNPMCJ/C8m/qAopjSqFeXJ3UJpAmRGAKP46YYWoyISRm6UFq7VVgXW 34PAmzbMnX3jFGcsSICO1jNis/SqjmVgzx4QSf7ak8xuOCQ5r8rs6Qiamih8zZJOqLBkXd WGh7nJ4r2BR1dxdKGL/sS61YaJ4Pu4mDLZaKY9QVnIZma6sREmxUc5/9ebWUhQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from localhost (unknown [IPv6:2a02:a03f:894b:4700:14df:f817:b136:7219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: tijl) by smtp.freebsd.org (Postfix) with ESMTPSA id 4N80cj68nTz12tW; Fri, 11 Nov 2022 13:56:53 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Date: Fri, 11 Nov 2022 14:56:35 +0100 From: =?UTF-8?B?VMSzbA==?= Coosemans To: Gleb Popov Cc: FreeBSD ports list Subject: Re: Temporary variables in make .for loops Message-ID: <20221111145635.045da586@FreeBSD.org> In-Reply-To: References: 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ThisMailContainsUnwantedMimeParts: N 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= ${package:C/[\.-]//g} > > MASTER_SITES+= 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 := 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.