From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 906 invoked from network); 16 Dec 2022 08:13:39 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 16 Dec 2022 08:13:39 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1671178419; b=MVq6+efMkcilYHUtdvTIuCxneM2V6yQEZUqY+rMMJ4roZcVPB5J+6dPSTH9K3w/rU/9LacZl3q cAJfaBHSnbLm8jlO0tR5ZbIcKOi/z34VvrnPZf+cSG1aSt/9DUka5iyxR1yB5cMlq/kct/DClr MkmdN7w0LQfpaRXzVED78J+e85wBA8ZMOjRsGTSzmbchyfk3tVOUoo43OYHmCPcmt+lw9DfD+m eWSjgZ93KnbY89YlnXhVUrA3DhDtlHCXT/KcdunbRyT2lDcRGpVG/s6GV7FgMMioFXnuNM6Wha Lkn/q6eghEjLKIApRyVIv3ahgTJ+xXC5myKIa5VIcuQIiQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-yw1-f173.google.com) smtp.remote-ip=209.85.128.173; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1671178419; bh=W92oQkuIgA0SULOCkyMYi2hAC8qATQJHd5eDrKcq1RU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=BFjDE+gikzI+bjsVor24mdwQE7g5OgQhfxHwAoaJ98NHdJD92J8roIel2IOQD8qRk/ohDjS7Pj lWraH/cqu1eE46iSgA0J4vY7Ri+TUSOjFm2RVzBbEcGxTunPiEFA4LVCZLUAqSlVVj7mFiDlLk beBBNdHCuzSD/fg/gloXNvwWGAIIp7TEv57pc4m3vei62qpCNFrAAJj/nie3ogJouwd08LrsPz +DkAB6SBjGfdJpW/F2hXrp91Nm8KHAeRiDYwwmI8e+reNU891q8JILkviR9vM78Dx8grFNamXz yMt78relQt8JOR96SE6DH5FhtrUIQD2w/pbnmdEqW2NueQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=iDfgEo+oH6LVL+K9MhjNMvuy61xJbwcmbIFI4XWuVdg=; b=GmwTby5dJyUjqRwBsYz0bLR2YP hIN9RGQcvOkQQwO2t0Drmq2gjEvp42a0vYnoAgnPp2dLXTCOiv9NIUY+gvQCJEvx9I439HAKwbMYT reisW91caoNnDcS19SRk+FqXw5qIZMBrSXiZ58pz7ZTl45sEt82gHG2WAkWyqEYj7EOF999dcm604 P33YuetyW7yY2xJAv8mXWM35B7g3eP1q5lHWcGwUiP119mBqKYe+dg52SDkjY0FrGOQ1DlhTS3/b2 jwxSwm/8Yu3VpCRGw2bf9ebM89tIdl2S0dkPCiymkGGSmp7m77BIYzJ7p/crLdf6nImNwq64VyA99 gwXCwQIg==; Received: by zero.zsh.org with local id 1p65qb-000IVa-5T; Fri, 16 Dec 2022 08:13:37 +0000 Authentication-Results: zsh.org; iprev=pass (mail-yw1-f173.google.com) smtp.remote-ip=209.85.128.173; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-yw1-f173.google.com ([209.85.128.173]:44818) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1p65pq-000HoJ-Rv; Fri, 16 Dec 2022 08:12:52 +0000 Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-3cbdd6c00adso23123857b3.11 for ; Fri, 16 Dec 2022 00:12:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iDfgEo+oH6LVL+K9MhjNMvuy61xJbwcmbIFI4XWuVdg=; b=ctQEJBy/kiApbs5r/JgPLPUbe5RjdeORk0lKryp0wYpJLTLMYY2RilhDiJy8lYFy18 TBathcrECUUIlJNQe1V4OiM0oanMc86y5X5bYSaED+yAe9ODh11yFtZOexqG2vP3xf4T 9IMHWYr6+wprqp/gheXYRjyvOIR4c0d7nsRriC6SyMjdRkd/fNF7k0YYTwEvHPycYDW+ Naw0rQQpVMki44au3Y7t3qrPpdm6K5iqS46pKV2QGRAFeQwt7G9rx07MexpAcsMfScrq XjjW0b59gWY8p1jHJKVqlTjA0+iavCGFatIuoIum0w38KdpkLL8z5hhI//qGTFx1CTZb X01Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=iDfgEo+oH6LVL+K9MhjNMvuy61xJbwcmbIFI4XWuVdg=; b=JNlyLy3ByVuuR+MvU2CxSr/a6JzXiOv4UuslwWPHMhh2A1KcpbrmuJ5drsPZsm2uIQ P9olb2J8V1tkwul8dTKoUESC+/MGyKA6uElKQkYe1jDoC4ylkTsfJBn7xVo0yZu+7aKv 4x7swkyn4Y29fOaY7yeBLdlSUc2uOZ4xPptTb0OYnoKyhFyPDpB4YzdKBhrBo0cYvHBr PbMZMQCF2qIeyCA4TaJ3eZJ+xN8f/OtRUjsCjNg8ymV85QoheoW0IAiGUSMmLD8u+K83 Oj5aWxDfng+imC0K26dB6osxjWDKHary2KFfYQxnPfGEy0UTByKujS2AhLa/Z+RvFJ8q RwfA== X-Gm-Message-State: ANoB5plzpgZSu3//DEPgk/zCWAG+ezZhG4ybJuwhtwRqmU9dwvEBjM7T Sl4r0hZU7RsT61BjOyYNMQg2g29JrFlV9S9ASZM= X-Google-Smtp-Source: AA0mqf7uI+kGDSB4XW2gacZEd3I/BIWdc0fkzUNjm2eDl13udHcj8gzn2+juw+ZIIn4Fae87mwfAcYFaOE3Ethy4sOE= X-Received: by 2002:a0d:c6c7:0:b0:36c:dd56:ce59 with SMTP id i190-20020a0dc6c7000000b0036cdd56ce59mr12137667ywd.321.1671178369332; Fri, 16 Dec 2022 00:12:49 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Roman Perepelitsa Date: Fri, 16 Dec 2022 09:12:36 +0100 Message-ID: Subject: Re: uninvited members of associative array To: Ray Andrews Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 28553 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Fri, Dec 16, 2022 at 12:48 AM Ray Andrews wrote: > > I just noticed something. My big array has ten named elements but if I print it: > > printf "%-20s %s\n" ${(kv)main} > /dev/pts/2 I just want to point out that in general you need to quote the array expansion here or you'll get surprises if the array has empty keys and/or values. Consider this: typeset -A main=( foo '1' bar '2' baz '' qux '' ) printf '%-4s = %s\n' ${(kv)main} And the output: foo = 1 baz = bar 2 = qux Notice that the output is wrong. Quotes to the rescue: printf '%-4s = %s\n' "${(@kv)main}" Now it works: foo = 1 baz = bar = 2 qux = Roman.