mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Mike Frysinger <vapier.adi@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] kbuild: fix warning when domainname is not available
Date: Tue, 15 Sep 2009 11:38:19 +0300	[thread overview]
Message-ID: <94a0d4530909150138y3fd09be4te62261bbde768893@mail.gmail.com> (raw)
In-Reply-To: <8bd0f97a0909140643x1f9c6478r51dcd762d6ba485@mail.gmail.com>

On Mon, Sep 14, 2009 at 4:43 PM, Mike Frysinger <vapier.adi@gmail.com> wrote:
> On Mon, Sep 14, 2009 at 04:25, Felipe Contreras wrote:
>> On Mon, Sep 14, 2009 at 7:46 AM, Sam Ravnborg wrote:
>>> On Mon, Sep 14, 2009 at 01:04:11AM +0300, Felipe Contreras wrote:
>>>> On Mon, Sep 14, 2009 at 12:58 AM, Mike Frysinger wrote:
>>>> > On Sun, Sep 13, 2009 at 17:42, Felipe Contreras wrote:
>>>> >> On Mon, Sep 14, 2009 at 12:12 AM, Mike Frysinger wrote:
>>>> >>> On Sun, Sep 13, 2009 at 15:38, Felipe Contreras wrote:
>>>> >>>> +  if $domain; then
>>>> >>>
>>>> >>> is this really correct ?  i think you meant to use:
>>>> >>> [ -n "$domain" ]
>>>> >>
>>>> >> What is the difference?
>>>> >>
>>>> >> $domain unset
>>>> >> test -n "" -> false
>>>> >> test -> false
>>>> >>
>>>> >> $domain is a valid string
>>>> >> test -n "string" -> true
>>>> >> test "string" -> true
>>>> >
>>>> > except that you didnt invoke `test` anywhere.  you're executing the
>>>> > contents of $domain.
>>>>
>>>> Ahh, I'll update it to:
>>>> [ "$domain" ]
>>>
>>> Please use [ -n "$domain" ].
>>> Be explicit about what you do.
>>>
>>> [Likewise in c we never omit "int" just because we can].
>>
>> In fact 'int' is implicit of 'signed int', and 'long' is a shorthand
>> of 'signed long int' and so on. Also, AFAIK 'if (foo)' is preferred
>> over 'if (foo == true)' or 'if (foo != NULL)' and sometimes even 'if
>> (foo >= 0)'.
>>
>> What's the point of going for the explicit form? Make the code less readable?
>
> your argument here is the opposite of reality.  while some of us are
> aware of implicit `test`behavior, not everyone is a shell scripting
> master.  they look at [ "$foo" ] and dont immediately get the
> intention.  or perhaps someone typoed and didnt actually want -n
> semantics.  add the whole *3* characters and be done with it.

I consider myself an expert in bash (or at least was some time ago)
and I still need to run 'man bash' in order to see what the hell -n
means. On the other hand, what can [ "$foo" ] be confused with? To me
that can be assumed as: $foo is valid.

In any case, I don't see that idiom being used in the source tree
(which I think is bad), and I see -n being used in some places, so
I'll send a new patch using -n for consistency.

Cheers.

-- 
Felipe Contreras

      reply	other threads:[~2009-09-15  8:38 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-13 19:38 [PATCH 0/5] Trivial warning cleanups Felipe Contreras
2009-09-13 19:38 ` [PATCH 1/5] Trivial whitespace cleanups Felipe Contreras
2009-09-13 19:38   ` [PATCH 2/5] kbuild: fix warning when domainname is not available Felipe Contreras
2009-09-13 19:38     ` [PATCH 3/5] kbuild: mkcompile_h: trivial cleanups Felipe Contreras
2009-09-13 19:38       ` [PATCH 4/5] acpi: fix trivial warning Felipe Contreras
2009-09-13 19:38         ` [PATCH 5/5] acpi: fix trivial warnings caused by previous commmit Felipe Contreras
2009-09-14 13:55         ` [PATCH 4/5] acpi: fix trivial warning Daniel Walker
2009-09-14 14:34           ` Felipe Contreras
2009-09-14 15:02             ` Daniel Walker
2009-11-12  0:23               ` Felipe Contreras
2009-11-13 17:43                 ` Daniel Walker
2009-11-13 20:28                   ` Felipe Contreras
2009-11-13 20:37                     ` Thiago Farina
2009-11-15 17:15                     ` Daniel Walker
2009-11-15 17:27                       ` Felipe Contreras
2009-11-15 17:32                         ` Daniel Walker
2009-11-15 17:54                           ` Alexey Starikovskiy
2009-11-15 17:58                             ` Daniel Walker
2009-11-15 18:10                               ` Alexey Starikovskiy
2009-11-15 18:09                                 ` Daniel Walker
2009-11-16  1:27                         ` Lin Ming
2009-09-13 21:12     ` [PATCH 2/5] kbuild: fix warning when domainname is not available Mike Frysinger
2009-09-13 21:42       ` Felipe Contreras
2009-09-13 21:58         ` Mike Frysinger
2009-09-13 22:04           ` Felipe Contreras
2009-09-14  4:46             ` Sam Ravnborg
2009-09-14  8:25               ` Felipe Contreras
2009-09-14 13:43                 ` Mike Frysinger
2009-09-15  8:38                   ` Felipe Contreras [this message]

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=94a0d4530909150138y3fd09be4te62261bbde768893@mail.gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    --cc=vapier.adi@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®