Re: [PATCH 3/6] GIT-VERSION-GEN: Use sed instead of expr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"lufia via GitGitGadget" <gitgitgadget@xxxxxxxxx> writes:

> From: lufia <lufia@xxxxxxxxx>
>
> Plan 9 don't have expr(1).
>
> Signed-off-by: lufia <lufia@xxxxxxxxx>
> ---
>  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.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux