All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: linux-kernel@vger.kernel.org, lukas.bulwahn@gmail.com
Subject: Re: [PATCH] checkpatch: auto detect codespell dictionary path
Date: Mon, 10 May 2021 10:39:05 -0700	[thread overview]
Message-ID: <630fc44bfb88f8d3d542c084c2d9f7c0a6d8aea7.camel@perches.com> (raw)
In-Reply-To: <20210510171127.15056-1-dwaipayanray1@gmail.com>

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.

> +		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.

> +		if (-e "$dictionary_path") {
> +			$codespellfile = $dictionary_path;
> +		}
> +	}
>  	if (open(my $spelling, '<', $codespellfile)) {
>  		while (<$spelling>) {
>  			my $line = $_;



  reply	other threads:[~2021-05-10 17:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10 17:11 [PATCH] checkpatch: auto detect codespell dictionary path Dwaipayan Ray
2021-05-10 17:39 ` Joe Perches [this message]
2021-05-10 17:54   ` Dwaipayan Ray

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=630fc44bfb88f8d3d542c084c2d9f7c0a6d8aea7.camel@perches.com \
    --to=joe@perches.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.