Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2797575pxj; Mon, 10 May 2021 10:56:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR4GOYhdBMn4TeNMmxsVgvit8Y6rIOpSt5eNVAY0ky029MDOL4MCyvvjPeehfV63x46Pg6 X-Received: by 2002:a92:d7c2:: with SMTP id g2mr23362022ilq.265.1620669384780; Mon, 10 May 2021 10:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620669384; cv=none; d=google.com; s=arc-20160816; b=pvsRUMHaxHKQDtfDk2vEeNgvc9cOH33TQ5QlS+//NOML2ouxrp3OLiGdq+CHNt3hKr Pngbn1uUyJvXLEmbKyZG9h6h4xmH5+f1LQQDKpEsgKzTk75OoEYGonLpfHmbJ3CjkD1p bWxHsn3mS2097rD4M1E2eg6u7iNNMYCDpBfpDLn5w6tg9dZ9Nvo+1/RLk7F5qvg87rJf khHr04j5jlWy4Q9hCSOPKPdj/YGvS7O/Lc5D7Z8AnAIR7QM+AnYRwxa9peXvUd5Nr4rL oHyk0IkbgzUZCH42xEtePEhZPkVOpJQNdmo+uN0NnND74SPX0s/Aavlsl1bgXzS0BsdN K8nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=7DBXjIiwreoSMBulhj9z8uemdOR1wtk9OGoK/dlXrlw=; b=XtkSxk6VBps/4EJm945oCOkJ7U2oZ7FrNp5m5UfBq4k9jRjTphblvju5/++0UD3I7f qWcfY2o3LH21Eas5gv4fYncgnxnV3FCK9EBx3Q+UQCzOeI8dEQnlmEG4G1PPqnP/WGZi bUxAXs7LaOfN5yh/eAPQG6IHBa/Cxc8xqp46GbPg+XstiM93BLWz6TL2BV2eQOPqSkRA h9+kIQFsFTUuGB/9r0maiZFlg8K95a1ReW+TozuLKLoFRwypOTtKIx8x6WIZxthEEJoN fJHNZHUkWCQyl1WRP4ISllJ6r2iTfFV/ipNaHnQQ4A2HLEHU5WUaMv1Du1lJ93dkd6aw JQxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kI1VsBmq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si16165868ioh.94.2021.05.10.10.56.12; Mon, 10 May 2021 10:56:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kI1VsBmq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233074AbhEJRzZ (ORCPT + 99 others); Mon, 10 May 2021 13:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231512AbhEJRzV (ORCPT ); Mon, 10 May 2021 13:55:21 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E356CC06175F for ; Mon, 10 May 2021 10:54:15 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id 2so24669411lft.4 for ; Mon, 10 May 2021 10:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7DBXjIiwreoSMBulhj9z8uemdOR1wtk9OGoK/dlXrlw=; b=kI1VsBmqooHdHR2wK2FW9Ig7MpJ6Jnv+jFiPsF6HkNbF+b8VVl8DmxTNTfP5pPtQ0j C8zlDuqgm/LpY1XPq7E4zUQF+oP7CNQOxUuqeu7z0rmWPZFLICPCptijhGZoFoUI0z1P HkpbxputLmAYvIty3BfaS3q9IUM57VE3AEcSHFdM7BZNoA74uJVuzUNAtKNxZQqzdWyK GRmIvjRxARlykjpWe3DKrjUD64qa1fEpTEaTDBpLus1aQawDnXIulbOhihD+9zVBG0MQ w//+PNR8qjOB9U2QX/JPuKXPlZS33XkTNz5VBENgXSJKkcJuCmhPnAb72HMK9sDuocaZ EMyA== 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=7DBXjIiwreoSMBulhj9z8uemdOR1wtk9OGoK/dlXrlw=; b=op4dXPJMWH52dtBDZXMUF/nSiaa7N5poEUf5XcuLE6DRxTOF8w9QZsHyRNhYZ8pNCj l/YPHPvN49LVq1Vo2yQr9qF5Q28V1tsLatqEVp+KeJy0nN8N6+x2mrBbUWgc2A3ltAvt M5YZKP4W40QsiPbEJX+kZstoiYYZTsPYcxxwGDTEf8g/We+ssrCJpssLSC92MZiExCHW LETYk4vMGipkr9nJ+77EcjljqqCmVVGIC0pAlFcq8BGC7mRwfJcy5qY+WEUJgmN8Ae3w WIy1PXQwICyzUIOsss8rTM/FeATMTr/vDifAwJS7YzOhHzBXZDeCAiPWHaS+2fJqKVQ3 1WyQ== X-Gm-Message-State: AOAM530sOD/FmcJGVb27UdVSbqZ46PLZdZbL106SsDmq07xpZRBfGw72 UMf0iy0isJhgF8Oz2KJjVSpoisO47wkFHFLjJdMlF5nJiMNFkw== X-Received: by 2002:a05:6512:1190:: with SMTP id g16mr18626589lfr.342.1620669254344; Mon, 10 May 2021 10:54:14 -0700 (PDT) MIME-Version: 1.0 References: <20210510171127.15056-1-dwaipayanray1@gmail.com> <630fc44bfb88f8d3d542c084c2d9f7c0a6d8aea7.camel@perches.com> In-Reply-To: <630fc44bfb88f8d3d542c084c2d9f7c0a6d8aea7.camel@perches.com> From: Dwaipayan Ray Date: Mon, 10 May 2021 23:24:02 +0530 Message-ID: Subject: Re: [PATCH] checkpatch: auto detect codespell dictionary path To: Joe Perches Cc: linux-kernel , Lukas Bulwahn Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 11:09 PM Joe Perches wrote: > > On Mon, 2021-05-10 at 22:41 +0530, Dwaipayan Ray wrote: > > The codespell dictionary was moved from > > `/usr/share/codespell/dictionary.txt` to data/dictionary.txt > > under the codespell_lib installation directory. > > > > Checkpatch still uses a default absolute path for it which will > > no longer work on new codespell installations unless the path > > is specified through --codespellfile. > > > > Detect the codespell dictionary path dynamically during > > runtime if the default path or the user provided dictionary > > path does not exist. > [] > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > [] > > @@ -889,6 +889,13 @@ if (open(my $spelling, '<', $spelling_file)) { > > } > > > > > > if ($codespell) { > > + if (! -e "$codespellfile" && which("python3") ne "") { > > + my $output = `python3 -c "import codespell_lib; print(codespell_lib.__file__, end='');" 2>/dev/null`; > > It doesn't seem to me that using python3 is a great way to invoke python. > Maybe test the external command return $? when codespell isn't installed. Sure, I will add that. > > > + my $dictionary_path = dirname($output) . "/data/dictionary.txt"; > > Unlikely, but this could still end up with a existing file of /data/dictionary.txt > that is not a codespell file. > So does testing for the return status give us some guarantee here? The dictionary path should be relative to the codespell_lib directory, that's what the codespell people writes. > > + if (-e "$dictionary_path") { > > + $codespellfile = $dictionary_path; > > + } > > + } > > if (open(my $spelling, '<', $codespellfile)) { > > while (<$spelling>) { > > my $line = $_; > >