From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 51B7422BA6 for ; Mon, 22 Jan 2024 03:05:38 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1705889138; b=S9qlmDl+mqTOd4oGPtbPEml5nWZG4RTOHgMXIt3gaBcyLz8jLe6b8yXJrcVChTa/J3d4xv+Z4l eJc1C483nQ3pcbYf2a8AlTIuG5T/02Ovac+1bSkbQ6/7tSCPclBod/oKjCPlPxVrrA/Xih6anp Gq7+lC4erHEFkaxjh47M/R0qXzys4LA87q0V8/OZVDA+9eH2YWaf2yAQ+j/nXn99vdA13nDxgI hHHiM7ffV088Ht8o4+3dJ0ofAK533WNB2Ezfoor2UhZysEsy3VdnmQsB43mw0+1QcR2Mnlydr9 gnaBAHqRkJViTm/3QAU9xsTvnij64eos6oyIzUFH2Cuu1w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1705889138; bh=liZfMoszCZNyWUt9SwVoebuFrW6KSKIN2NKcZktNHnQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=M/rKzBFs3d+XoxjIRhnuJRna0kTT0xU7irF3P9CHYGwjrXHzwG55LhZHh7Jwkg/aVaa9cFMED4 wp3NProzQ1NY3iwC/QA/Qu6borUM5cjxh/MmQhfLREuKNGhVF8LpwaZZ9VCLTo1fOWPlYOQDMT mGrhwAENMDDyw2hxOIPSlmi64g+ytz7IRdK+rTOI0x7Rds5CssW4GKArlxkR4CDeK6svbjNjaZ F259TYirow58oKbypZ3SKaR9/kRW/01UVQw7KnZJEQgoKJg7wVRQpUn+7af7bahzkJOkX1WnJO qEa5bgv8QCveAvIE8gqrRACPeO3bkSQTynq7OLvQ/Kcefw==; 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=5BDB+Uz024e4of3eb894aWwfBlVvkxLdXM7/l4W7bmk=; b=X0dCGk6+d3quRI7xAmPFKsx5PR BiF2hiUZwl/ATae7zmw+CTnYuq1oHHSUWqATicaHJ/kQ+uTGy4yyiGhJlwqpuiwYTG7GdxjlOy4ja KDR/+Zj73uCNlGNktupSThMy89fc2UQGRB8nFoEWk0Az6NLkBej3IjFJdJsJ5557Yh+pld+26J+zG cpppDsMTJdryuxq7zVWQzRQI36nZi3YNPNNpXl/D1dveGR7WUdUD2mN8OPi4CD03PndYtoJWC7dpb IGSV2HNOexcWXPJV3k1oeIj07od99xTlKBzxNjj4CI8Ly30wycUEGzbqNs+5G8qjuPzQmegdsaojn n8wwb8Bg==; Received: by zero.zsh.org with local id 1rRjgw-000OYj-PL; Mon, 22 Jan 2024 02:05:38 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f48.google.com ([209.85.218.48]:50409) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rRjgi-000OEr-LJ; Mon, 22 Jan 2024 02:05:25 +0000 Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a2ac304e526so249090066b.0 for ; Sun, 21 Jan 2024 18:05:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1705889124; x=1706493924; darn=zsh.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=5BDB+Uz024e4of3eb894aWwfBlVvkxLdXM7/l4W7bmk=; b=jv6vWVgYGq4V+LRhuEbUAnPP2mYZJhoFyn8fC22Re3aScr6w0aGswi8upjcULux+Vj Nd0YdeBw6V8+VXxdZeatInmfLxYvU43542psf6WfoyRY777obVsxLBVQ/7l7oSChdYDA T8ooc6c4X805rVBc+kkGXjY1uZApw4738pqyNywdkRJJRpxl5TVdzVL+pAkwv8X7ZVdE TczU1AWmTJ9K0l8Gd7NURmVDm39JdagxefkOQx2abgxlctr+b2ekFb36PEl1L556j7cH egGwXK6uhIQtEuQ0BJJ+nUAZ7gzC+Ai67ZbCfBIKwURzFbTfZDkQp5hLFe00cG/6fDeB 18cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705889124; x=1706493924; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5BDB+Uz024e4of3eb894aWwfBlVvkxLdXM7/l4W7bmk=; b=CNhNySX0JxsQRl33oNes9q6RvD9Q2DSVY3ReRT2SMEoKBHdWHLLimGtQvDleu6PPDZ sSsXzyV13D0N5CpMKZz5cn1Y5ZFqsEm8c4LzmInniJtMEqijB1W59i4gT3az2z+HF0TS 0rnQxifCAfjycSn0qXUadlnyPxgIZ74mNbaaahzn5JNh/U9+XZfGIetsCtUuvQU/CkV2 LQDuCLHqnPRQNw4az5jts31GMWC2HSeaWdrshjVfWfp3kvdNS26ar7+fEi4BZvQUPrfU 1FoNq4vKWbb7hNr2P7Lh0ibbVey3L8NauB71Hv67opqwv6qCC45+TrKnAGYNn2iT3OlF vKRg== X-Gm-Message-State: AOJu0YwFXcs+ejtSFKZZlK92nxP+j9CwsEmXIleXs4yx9RWUvF5kpO7i T659XOok5QsKYqLbELmQytDHGCQm1FJC4nqwBo2qYUG6WNP2yQR2S0x9qxDY4HuhIx9s5WsH92t z98ZdVZV7DLKpD/7P5u96NR4SZi9kBgbe0yJe6vZcEBKUMQyVrQ== X-Google-Smtp-Source: AGHT+IG2rlVvcDqX+sEOnbpJldwO6b5Kbqv23BmCadI8xaF9Lsh/N1QjYQo6O28PRAUGq5ASII8xo0CQwT70zUq9wfQ= X-Received: by 2002:a17:907:4d0:b0:a2e:9169:ce7d with SMTP id vz16-20020a17090704d000b00a2e9169ce7dmr1428063ejb.145.1705889123730; Sun, 21 Jan 2024 18:05:23 -0800 (PST) MIME-Version: 1.0 From: Bart Schaefer Date: Sun, 21 Jan 2024 18:05:12 -0800 Message-ID: Subject: mapfile and unset: Does this actually work? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 52497 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Doc says: mapfile This associative array takes as keys the names of files; the resulting value is the content of the file. The value is treated identically to any other text coming from a parameter. The value may also be assigned to, in which case the file in question is written (whether or not it originally existed); or an element may be unset, which will delete the file in question. However: % touch removable % zmodload zsh/mapfile % : $mapfile[removable] ; unset 'mapfile[removable]' % ls -l removable -rw-rw-r-- 1 schaefer schaefer 0 Jan 21 17:17 removable I tried several variations of this and I can't get mapfile to remove anything. Looking at the code: static const struct gsu_hash mapfiles_gsu = { hashgetfn, setpmmapfiles, stdunsetfn }; There is an unsetpmmapfile function but it doesn't seem to be used anywhere. Even after recompiling with that in place of stdunsetfn there is some strange behavior: % zmodload zsh/mapfile % echo 'text' > removable % ls -l removable -rw-rw-r-- 1 schaefer schaefer 5 Jan 21 17:42 removable % noglob unset mapfile[removable] % ls -l removable ls: cannot access 'removable': No such file or directory (so far so good, but) % echo 'text' > removable % () { local +h mapfile; unset 'mapfile[removable]' } % ls -l removable -rw-rw-r-- 1 schaefer schaefer 0 Jan 21 17:43 removable % noglob unset mapfile[removable] % ls -l removable -rw-rw-r-- 1 schaefer schaefer 0 Jan 21 17:43 removable Using "unset" on the local has somehow made that file inaccessible, it just gets truncated instead of removed. I think this is because: % echo ${+mapfile[removable]} 0 The hash element for that file is still present but tagged PM_UNSET? I started playing with this because I was concerned that having a local mapfile go out of scope would cause files to be removed, but even with unsetpmmapfile that fortunately doesn't occur.