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 CF32F28273 for ; Mon, 5 Feb 2024 00:14:30 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1707088470; b=nC7ra68bs/5VRqXwmCxUtg4nrMmV2x62eSdREE4ch1KAsQXSFh8CYKEOJRO2+uCD0SgBpZlbBh 5z0y33xpC7Cw3Y1SDkt5NBpsghUFuXe9VoJnYFHT/d0knOXIUigpDvwEAJi3JrevtdcNvadRnL Er+2bQrwGjWEcEBWy9Q5YK3zCYudwPfxMX4Woc8B24GI9p6MdhdXQiPf0eHsvnGwW0sr7FQgjs 758goBfpNu9xCkIv4l/3ZHJSLKtLI10kqM4H1u53lJpXHPewPGB0X3pq4TEEa8EPK1PT201xMl bIL6bAtut8wymvCNyT/pGnpFdanMGiExVX8NuZMW3d5qQw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f50.google.com) smtp.remote-ip=209.85.167.50; 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=1707088470; bh=umemqEXAMle0rtg1LhjJHFtVou0eZ4MYQruZKIjBqjg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=odjeES3tCfGB4wtvLADJriPSz5puF9bryJzvazdrKc7ZjCNh9mPBngnSiD1WGZ9MR0O5yItuyc /oSoVgwYG66lvDMWfWH3YLGST9vuGRLq6LcdSSPm+aLMlvfTyrgNc+nj0aqmPRiITN1klTUVM/ qro/KQ6L825SZdDSC16P6zJME/L43Rm0V1sGu4p9PGsbMiV42X9WsOZLQPE+E751GTn5SBlpoW ezR3VMLDbCray0Rct+PZVdk5bRilBXbXaCTaALQZ9AofeU0gSCuiFUoXOy60JcAFpaYVpyACYK ISfFaW7GLrgJkVy+k00Otl01DlPrYScpcc5IWP+mmsBysA==; 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-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6azWySIj1GPCcvPKHO8ei+sciIDow1Bo7LEReepno78=; b=TUnwwFOUOf83S/CjEKMMTR2ME6 qMYSeTr+WP0dq+FAXiLR/zn8efIj7GqZQ6GtKQYvTpBGfCtwyFa/lVTsfKcznvQUScEMxfMBLhSCG yzbjYwT56TLEoa/yuJL/8PFNrRWshLBhbPR0/0YJWV3dzMr5bP0J+eyJxk6XQRwdwWWW9k0X8tlUU 2tNsyDlypAL6VdfkeS7vZ8r/w00lS8sZDI/JK1f6sThqDHtjxrFkeJ4todRLvC9jcNrnyVMti6zI+ 8nUsYZjQX8hUhtXPR2rAeQzFshYLTkahL0awgTvAnrk40OSoqNDjP8Pf7xovaxjDZZLCZiZTz9MKp 9xKpv+YA==; Received: by zero.zsh.org with local id 1rWlgz-000BaZ-F8; Sun, 04 Feb 2024 23:14:29 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f50.google.com) smtp.remote-ip=209.85.167.50; 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-lf1-f50.google.com ([209.85.167.50]:49229) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rWlgN-000BG4-E7; Sun, 04 Feb 2024 23:13:52 +0000 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5114cd44fdbso982818e87.2 for ; Sun, 04 Feb 2024 15:13:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1707088430; x=1707693230; darn=zsh.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6azWySIj1GPCcvPKHO8ei+sciIDow1Bo7LEReepno78=; b=wblOYBMYEcYgLhqeKOUsazEa0UuFJuP3S+iIMOsdI8AhfFKfPlzie+yxrWlV5NP/Pp mjA0m6Yw4VQhci/gLDz0qDWIlW5HWUWRxZ3ymnFOcxwST9JjnuQr6GbW6qMa7NneBeqv CbKXAQyX8TSQHkioJnYKOJOsWqQFhHIy0mtq/py9WPmDENu/8Z0QeX7sLLnLnt8rjawi GKFuMH3hYK8Vzb9WRkE4ByHCDIsZp8gs6B7TcrbBZczk6/yDilkIUaWC5en9oPOLgiq+ xkSj7Vd+ID2MrUJCqFfPaFdXMCBJJwo8AtU+QSWWhnV77x3U8HFwi2L1tPLYoilldiZ8 EjRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707088430; x=1707693230; 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=6azWySIj1GPCcvPKHO8ei+sciIDow1Bo7LEReepno78=; b=QPuMJdvGanz3oDDJaOjk6ay/YVYly/Jj63xbOkLWTpTt8D/+lEkJKELD3KjFXbEYy/ 66Gtmgr9zFGtIO8t27o7GnYFGQQooOfPGPMCrOsk5aksFM9txrdvAS+u5VZadorAT208 wk2d3eM4SMZq5EeDLZ1Feu2H+U/On51IGW+n+dciBbkyx/1UzmjZX5w0AYWC8hND4WMJ v6cp5S4/1vS5ppBJ3tTdllFs6/Q3Oj6dCRO5EyuZffA6rR9zp1CWVYz47uDdQXgtfhP5 +INzaFcZ+u1jUwak3cwvKF5+hMqJar8itBLLXkfeDNTlTYHt1L6OSGNAICoEDFxWe7pv Y11Q== X-Gm-Message-State: AOJu0Yw+AgR1SmKjZJik3f/R82VXaSw2lc0YM8s85BVgqrFmSu0F7Gg2 qnm8fF0JbbZjEvl2C9bH+NWfKU6PwZ+2ai36O3DDyrosbKPSvX8iqLKOyYfIfq17rakb1TXtDk4 P0wR2byx9w7A2PXFaFb4Eobex7Eb9kcSSFtap X-Google-Smtp-Source: AGHT+IGkmecPGntpvm2xA3NMqcsprkfVN/IfqNrtujeYYYKe7xFqSB7gKUK1nPg4RNBTApm4Ad9Xyu2kKZ0utN8B2YE= X-Received: by 2002:ac2:4d99:0:b0:511:454d:25e3 with SMTP id g25-20020ac24d99000000b00511454d25e3mr2817654lfe.41.1707088430433; Sun, 04 Feb 2024 15:13:50 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Sun, 4 Feb 2024 15:13:38 -0800 Message-ID: Subject: Re: mapfile and unset: Does this actually work? To: "Mark J. Reed" Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52521 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: On Sun, Feb 4, 2024 at 10:04=E2=80=AFAM Mark J. Reed = wrote: > > I take that back. If the file is nonempty, then the file is deleted. If t= he file is empty, then it's not. So it seems to be an conflation of unset a= nd empty in the mapfile logic. Aha. In the "get" method from the gsu struct: /* Set u.str to contents of file given by name */ if ((contents =3D get_contents(pm->node.nam))) pm->u.str =3D contents; else { pm->u.str =3D ""; pm->node.flags |=3D PM_UNSET; } So an empty file always appears to [already] be unset, e.g. % touch empty % zmodload zsh/mapfile % print ${+mapfile[empty]} 0 This in turn appears to be because get_contents() doesn't distinguish a file it can't open from one whose contents it can't read. More specifically, mmap() on an empty file returns -1. The unset logic in mapfile.c is never called because the parameter is already marked unset. Perhaps this is more suited for the BUGS file than for an immediate repair.