All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <J.Sixt@eudaptics.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Johannes Sixt <johannes.sixt@telecom.at>,
	gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH] filter-branch: Avoid an error message in the map function.
Date: Wed, 04 Jul 2007 13:45:22 +0200	[thread overview]
Message-ID: <468B8852.CB36968@eudaptics.com> (raw)
In-Reply-To: Pine.LNX.4.64.0707041205250.4071@racer.site

Johannes Schindelin wrote:
> 
> Hi,
> 
> On Wed, 4 Jul 2007, Johannes Sixt wrote:
> 
> > -     test -r "$workdir/../map/$1" || echo "$1"
> > -     cat "$workdir/../map/$1"
> > +     test -r "$workdir/../map/$1" &&
> > +     cat "$workdir/../map/$1" ||
> > +     echo "$1"
> 
> I think this does not do what you want. If I read it correctly, it will
> not do anything if $workdir/../map/$1 is not readable. I think you need
> this:
> 
>         (test -r "$workdir/../map/$1" &&
>         cat "$workdir/../map/$1") ||
>         echo "$1"
> 
> But that is a little too cute, so I personally would prefer an
> if-then-else-fi, because that is the idea of that code snippet.

It does do what I think it should do. I tested it. Your elaborate
version is not required. The reason is that in the shell && and || have
equal precedence; if there is ... && cmd ... then cmd is run if the most
recent result is success, and if there is ... || cmd ... then cmd is run
if the most recent result is failure; in both cases cmd is otherwise
skipped and does not count as "most recent result".

-- Hannes

  reply	other threads:[~2007-07-04 11:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-04  7:54 [PATCH] filter-branch: Avoid an error message in the map function Johannes Sixt
2007-07-04 11:08 ` Johannes Schindelin
2007-07-04 11:45   ` Johannes Sixt [this message]
2007-07-04 11:49     ` Johannes Schindelin
2007-07-04 12:08       ` [PATCH take 2] " Johannes Sixt
2007-07-04 12:51         ` Johannes Schindelin

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=468B8852.CB36968@eudaptics.com \
    --to=j.sixt@eudaptics.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johannes.sixt@telecom.at \
    /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.