From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4IXOOY0WbGM3BwAAbAwnHQ (envelope-from ) for ; Wed, 09 Nov 2022 22:07:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id oO38OI0WbGP5UQAAG6o9tA (envelope-from ) for ; Wed, 09 Nov 2022 22:07:25 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 7AB7139AD9 for ; Wed, 9 Nov 2022 22:07:25 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ossHq-0001zV-95; Wed, 09 Nov 2022 16:07:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ossHo-0001zF-EU for guix-patches@gnu.org; Wed, 09 Nov 2022 16:07:05 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ossHm-0005Ig-Pv for guix-patches@gnu.org; Wed, 09 Nov 2022 16:07:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ossHm-0002Ou-9I for guix-patches@gnu.org; Wed, 09 Nov 2022 16:07:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#58812] [PATCH 0/5] Add --symlink option to 'guix shell'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Nov 2022 21:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58812 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer Cc: 58812@debbugs.gnu.org Received: via spool by 58812-submit@debbugs.gnu.org id=B58812.16680279899185 (code B ref 58812); Wed, 09 Nov 2022 21:07:02 +0000 Received: (at 58812) by debbugs.gnu.org; 9 Nov 2022 21:06:29 +0000 Received: from localhost ([127.0.0.1]:41060 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ossHF-0002O5-9w for submit@debbugs.gnu.org; Wed, 09 Nov 2022 16:06:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ossHC-0002Nr-3d for 58812@debbugs.gnu.org; Wed, 09 Nov 2022 16:06:27 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ossH6-0005Cp-TB; Wed, 09 Nov 2022 16:06:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=xdmQ9rTv8g8+R7xitWKpx9Th6/JxLQyL9ezzcowbuxI=; b=ogJHSlxkqACJeSwMInYB OmPd7+umGI9AqhLtsmn8h7DRfgafALJga+20dxaTtQGtdS+9ede7wL9PIDgA2+qoVq3k2jypruus3 VX8Z5F+iiWYaIW2lJ9+3fLJqSDJdjWcZUbnyEp71Sv/bCnS56oN9geIIre+P+6chu5Y2faHkGkznP JV/GvLXIHkjZNEes4yHIUJYgzVKT6V5bwWFmDSyNoaN3kRwNX7hj3EefpTYkZghUzmuQTZsNQ1oqd ELYmXdYJFuqLrltftfpU87NyiWURH5IoME+xdYUKGm0CgXKHRX8xPoovMZcbx9sdBLpTus518r9Es wVNUjRgbyU9uug==; Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ossH5-0005fR-GM; Wed, 09 Nov 2022 16:06:20 -0500 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20221027035100.28852-1-maxim.cournoyer@gmail.com> <20221027035100.28852-3-maxim.cournoyer@gmail.com> Date: Wed, 09 Nov 2022 22:06:16 +0100 In-Reply-To: <20221027035100.28852-3-maxim.cournoyer@gmail.com> (Maxim Cournoyer's message of "Wed, 26 Oct 2022 23:50:58 -0400") Message-ID: <87leojon1z.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1668028045; h=from:from:sender:sender: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:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=xdmQ9rTv8g8+R7xitWKpx9Th6/JxLQyL9ezzcowbuxI=; b=Fq3rIgEwfVXOXNBYBHy/pgLK4ZoWPM3uWmsoHmFNxxgpTTQxTBvXsqS0JzljZrm8uuyOdV 6TnSd8CSjCf7WsVG07HDDm9wJmlX3PzIj8hEdyzZ6IUZKuPJQHYMQno3SM8j0T95nCl6VP ijvAu2nL6ZG0lC6LNqs6WIpTRvmxgbXfkB64dH4NoZmJT8it1+zmsBDj1gwqiTGEei1WL7 pEGnwM/jJgAoOwONMQAxXbBqwE60V6gx2oT1CvNVfWGfg0bP9zxQC8FcpALiPddBCDH6SY Nxm4h5z+yU1G26Go1h/reqLrIW9S9jn1wf6PJzLvFlxdMFnkb65RB/305WE+cA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668028045; a=rsa-sha256; cv=none; b=og11ObbHyTyD8C+0rbyxQTHRHjGF7CN8MTi66nYmSzDA/THrk8OYC9K7Utf1tSuzeMDkMC qTcNxTZVK21TpJzKcrhFN5VsnZMFdAfhQmRinqkBdWZZxEIBKw71a0OCra4FvJbJZVe7TZ MeJ62GOYeD2nVkhHJFQJpA3URwy8ZfCtH/h3MJCBLkPjflx07COyEzha9Zsbww3LugwO1S pL4UKH7nn+0sg2H4TTgS8jgUiHvDZMU++WP9cyQj8lki/dRLBBXff+5xj+ksSpQsTcZlo3 wfp3RpGcBFpSc278U5ZXUIxIEvhqcfPHYla1kJqOUxsclBImI/i3BcCYw7Jz9A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ogJHSlxk; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -4.22 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=ogJHSlxk; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 7AB7139AD9 X-Spam-Score: -4.22 X-Migadu-Scanner: scn0.migadu.com X-TUID: aFP39a+TMO2d Maxim Cournoyer skribis: > * gnu/build/install.scm (evaluate-populate-directive): By default, error = when > the target of a symlink doesn't exist. Always ensure TARGET ends with "/= ". > (populate-root-file-system): Call evaluate-populate-directive with > #:error-on-dangling-symlink #t and add comment. [...] > + (define target* (if (string-suffix? "/" target) > + target > + (string-append target "/"))) Maybe make it: (let ((target (if =E2=80=A6))) =E2=80=A6) so there=E2=80=99s only one =E2=80=98target=E2=80=99 in scope (and no =E2= =80=98target*=E2=80=99); otherwise it=E2=80=99s easy to forget the =E2=80=98*=E2=80=99 and refer to wrong one. > + (let ((new* (string-append target* new))) Likewise. > + (when error-on-dangling-symlink? > + ;; When the symbolic link points to a relative path, > + ;; checking if its target exists must be done relat= ive to > + ;; the link location. > + (with-directory-excursion (if (string-prefix? "/" o= ld) > + (getcwd) > + (dirname new*)) ;rela= tive > + (unless (file-exists? old) > + (error (format #f "symlink `~a' points to nonex= istent \ > +file `~a'" new* old))))) > + (symlink old new*)) I would avoid the directory excursion when unnecessary: (unless (if (string-prefix? "/" old) (file-exists? old) (with-directory-excursion (dirname new) (file-exists? old))) =E2=80=A6) (We could use =E2=80=98lstat=E2=80=99 instead of =E2=80=98file-exists?=E2= =80=99 if we want to allow symlinks to dangling symlinks=E2=80=A6) Ludo=E2=80=99.