From nobody Wed Jul 28 17:36:33 2021 X-Original-To: freebsd-current@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 6BBAF12AE108 for ; Wed, 28 Jul 2021 17:36:51 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (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 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GZgnt42TXz4RZY for ; Wed, 28 Jul 2021 17:36:50 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x82a.google.com with SMTP id k13so1914800qth.10 for ; Wed, 28 Jul 2021 10:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FrAtbZWHSE8fYjtGNoSuIjCotZ4AjQWXCMiMlPH34JA=; b=fYUJ1MDSBBm0iQqDIqAp6UuIJ9js++eI/EVs4xkyanIq7L/H6G/ImSCIGS7QpsdxNg E724+b1LAs9paDcBTr3SmJsHNotx8mbhvA/XqgoTX7ganm8t+R0DrG/o7UtU+UOpmhbF Y4knI6O6me7ybupJAThLoA2SMsrLdaoBDNT6IniUvW9HHGYZB/0NvXDEnTvSwHtDdwH/ 2cn/KSLKS/k0af5KdrNZHhIdnQNES07tGWHZO4VukvHDHRiPYHJQl29K2pENRugiz3oy NULD0amo61QXODHurRle7llh8n3+4b/RDfA5boWTBud5oZkLkTdgv32h+XzJP3KqhIPO PELg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FrAtbZWHSE8fYjtGNoSuIjCotZ4AjQWXCMiMlPH34JA=; b=iOo5v28+nUgpOvxYpv35uWTArajc+lIVvvSG47P/NiSewhrwiKl5CoOPV2DrundNcU bONkRD5/aRDo0Ydl1//TGS9D0chm3GgEVoK9pSYrrQTGfISdtuWLyjTjooqdj5dJKEx4 z+rQClD1MabMhYdpmcfFL4pHKMgV8TpLrfanTXNG9cop06bzKzQV6G2nYriPbPrOZqrH /AnhIqlN7qyAfwCAkIOZtAh9S/Jf0AwTVB6iZawchP7jiaF5q4VXjWrDwWwiRCCBpyBS jgouORfgAni1z/UU3dCeGE7PyaSkJ7gLoiXcvtDOcOOiFRQuen2Ot9HMu0XNRULKmBKn qqiQ== X-Gm-Message-State: AOAM530JsSdxPSgrfPNdvDcuZyfx5RjJuMWtwe1sESe+PhDd7YYzR/ej v0qIs3XtbOrbrN/Yp1EmCIRCI7B77KNdNt6fqeUvViBvEH8j/dIU X-Google-Smtp-Source: ABdhPJwBgAACf4dDBqJy66xeGc2JRdzCy3vaGJHgU4imlJOCqcmdSqor5CiKbBNOKON2kYB5yKZunSg3KEc/pjVNdGw= X-Received: by 2002:ac8:5b8a:: with SMTP id a10mr610666qta.235.1627493804402; Wed, 28 Jul 2021 10:36:44 -0700 (PDT) List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 References: <8e1a8e3c-b062-7749-ceab-e500c1ab758e@protected-networks.net> In-Reply-To: <8e1a8e3c-b062-7749-ceab-e500c1ab758e@protected-networks.net> From: Warner Losh Date: Wed, 28 Jul 2021 11:36:33 -0600 Message-ID: Subject: Re: awk behaviour? To: Michael Butler Cc: freebsd-current Content-Type: multipart/alternative; boundary="00000000000015fdb405c8326ed1" X-Rspamd-Queue-Id: 4GZgnt42TXz4RZY X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: Y --00000000000015fdb405c8326ed1 Content-Type: text/plain; charset="UTF-8" On Wed, Jul 28, 2021 at 11:31 AM Michael Butler via freebsd-current < freebsd-current@freebsd.org> wrote: > I tripped over this while trying to build a local release .. > > imb@toshi:/home/imb> pkg --version | awk -F. '{print $$1 * 10000 + $$2 * > 100 + $$3}' > 10001 > > imb@toshi:/home/imb> pkg --version > 1.17.1 > > Is this expected? > Why $$ instead of $? $ isn't expanded in '' expressions, so doubling isn't necessary unlike in make... With single quotes it works for me: % pkg --version | awk -F. '{print $1 * 10000 + $2 * 100 + $3}' 11603 % pkg --version 1.16.3 In awk $$n is $($n), so $$ in this context would evaluate $1 to 1 and then $1 to be 1. And then $2 to be 16 and then $17 to be 0 and then $3 to be 1 and then $1 to be 1 which leads to 10001. Warner --00000000000015fdb405c8326ed1--