git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "lufia via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, lufia <lufia@lufia.org>
Subject: Re: [PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr
Date: Mon, 05 Aug 2019 15:37:04 -0700	[thread overview]
Message-ID: <xmqqy307kzn3.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <df67a7e1d307d6a7a91ae1bba085959154006ed1.1564876327.git.gitgitgadget@gmail.com> (lufia via GitGitGadget's message of "Sat, 03 Aug 2019 16:52:11 -0700 (PDT)")

"lufia via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: lufia <lufia@lufia.org>
>
> Plan 9 don't have expr(1).
>
> Signed-off-by: lufia <lufia@lufia.org>
> ---
>  GIT-VERSION-GEN | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
> index a0766f64ed..754d4486f5 100755
> --- a/GIT-VERSION-GEN
> +++ b/GIT-VERSION-GEN
> @@ -26,7 +26,7 @@ else
>  	VN="$DEF_VER"
>  fi
>  
> -VN=$(expr "$VN" : v*'\(.*\)')
> +VN=$(echo "$VN" | sed 's/^v*//')

The expr utility is often a shell built-in, but sed is almost never
(as it is a lot more heavy-weight command).  It may not be a bad
idea to get rid of expr with a simple shell parameter expansion,
e.g.

	VN=${VN#v}

instead.

The original explicitly is prepared to see no 'v' at the beginning
(in which case it just passes VN intact), or more than one 'v's (in
which case all leading 'v's are stripped), while the shell parameter
expansion strips zero or one 'v' at the beginning.  So there is a
slight "regression" there, but I do not think it matters (certainly,
it was *NOT* my intention while writing the original to strip two or
more 'v's).  181129d2 ("For release tarballs, include the proper
version", 2006-01-09) snuck in the "all leading 'v's are stripped"
without sufficient explanation, but I do not think it was an attempt
to allow two or more 'v's.

  reply	other threads:[~2019-08-05 22:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-03 23:52 [PATCH 0/6] Port git to Plan 9 KADOTA, Kyohei via GitGitGadget
2019-08-03 23:52 ` [PATCH 1/6] Change HOME, PATH, and .gitconfig paths to be customizable lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 2/6] Fix C syntactic errors for the Plan 9 C compiler lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr lufia via GitGitGadget
2019-08-05 22:37   ` Junio C Hamano [this message]
2019-08-03 23:52 ` [PATCH 5/6] Add plan9/wrap.c lufia via GitGitGadget
2019-08-04  0:03   ` brian m. carlson
2019-08-04  1:26     ` Kyohei Kadota
2019-08-03 23:52 ` [PATCH 4/6] Port generate-cmdline.sh to rc lufia via GitGitGadget
2019-08-03 23:52 ` [PATCH 6/6] Add mkfile to build git and subcommands for Plan 9 lufia via GitGitGadget
2019-08-04  0:38 ` [PATCH 0/6] Port git to " brian m. carlson
2019-08-04  2:22   ` Kyohei Kadota
2019-08-04 20:22     ` Jonathan Nieder
2019-08-27 13:46 ` [PATCH v2 0/3] " KADOTA, Kyohei via GitGitGadget
2019-08-27 13:46   ` [PATCH v2 1/3] Change HOME, PATH, and .gitconfig paths to be customizable lufia via GitGitGadget
2019-08-27 13:46   ` [PATCH v2 2/3] Fix C syntactic errors for the Plan 9 C compiler lufia via GitGitGadget
2019-08-27 13:46   ` [PATCH v2 3/3] Support Plan 9 dialect lufia via GitGitGadget

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqy307kzn3.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=lufia@lufia.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).