git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Jari Aalto <jari.aalto@cante.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize
Date: Fri, 16 Apr 2010 18:11:11 +0200	[thread overview]
Message-ID: <201004161811.14259.jnareb@gmail.com> (raw)
In-Reply-To: <87wrw7qtx8.fsf_-_@jondo.cante.net>

Jari Aalto wrote:

>     Jakub Narebski <jnareb@gmail.com> writes:
>     >   +sub maildomain_sanitize {
>     >   +	local $domain = shift;
>     >   +
>     >   +	#  On Mac, the the domain name is not necessarily in FQDN format
>     >   +	#  Require a period in the string
>     >   +
>     >   +	if ($^O eq 'darwin'  &&  $domain =~ /\.local$/) {
>     >   +		# Nope, pass this one.
>     >   +	} elsif ($domain =~ /\./) {
>     >   +		return $domain;
>     >   +	}
>     >   +}
> 
>     Thanks for 2nd eye. Changed these in above:
> 
>     * Starting brace placement at function start
>     * Placement of else
>     * Maybe: use or "return" (debatable).
> 
>     But not these. Motivation:
> 
>     * The "$_" simplifies usage everywhere in the function. XP: less is more.
>     * The "and" is more readable than "&&". The "and" is also safer
>       due to its lower precedence.

O.K.


Note however that while setting $_ ($ARG with English) simplifies regexp
matching, you have to take care to use

   local $_ = shift;

and not

   my $_ = shift; 

And to use 'local'.

A bit of "difficulty conservation" at work.

[...]
> +sub maildomain_sanitize {
> +	local $_ = shift;
> +
> +	#  On Mac, the the domain name is not necessarily in FQDN format.
> +	#  Require a period in the string.
> +
> +	if ( $^O eq 'darwin'  and  /\.local$/ ) {
> +		# Nope, pass this one.
> +	} elsif ( /\./ ) {
> +		return $_;
> +	}
> +}

-- 
Jakub Narebski
Poland

  reply	other threads:[~2010-04-16 16:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09  5:11 [PATCH 0/3] send-email: --smtp-domain improvements Brian Gernhardt
2010-04-09  5:11 ` [PATCH 1/3] send-email: Don't use FQDNs without a '.' Brian Gernhardt
2010-04-09  5:36   ` Junio C Hamano
2010-04-13  8:43     ` [PATCH] git-send-email.perl: Add sub maildomain_sanitize Jari Aalto
2010-04-13 11:35       ` [PATCH] git-send-email.perl: add maildomain_sanitize() Jari Aalto
2010-04-15 12:47         ` Jakub Narebski
2010-04-16 15:49           ` [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize Jari Aalto
2010-04-16 16:11             ` Jakub Narebski [this message]
2010-04-16 17:00               ` Start encouraging English.pm (Was: [PATCH v2] git-send-email.perl: Add sub maildomain_sanitize) Jari Aalto
2010-04-09  5:11 ` [PATCH 2/3] Document send-email --smtp-domain Brian Gernhardt
2010-04-09  5:11 ` [PATCH 3/3] send-email: Add sendemail.smtpdomain Brian Gernhardt
2010-04-09  6:56   ` Jakub Narebski

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=201004161811.14259.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jari.aalto@cante.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).