From mboxrd@z Thu Jan 1 00:00:00 1970 From: Junio C Hamano Subject: [PATCH] git-sh-setup: fix parseopt `eval`. Date: Wed, 07 Nov 2007 23:09:29 -0800 Message-ID: <7vr6j15i3a.fsf@gitster.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: git@vger.kernel.org To: Pierre Habouzit X-From: git-owner@vger.kernel.org Thu Nov 08 08:09:55 2007 Return-path: Envelope-to: gcvg-git-2@gmane.org Received: from vger.kernel.org ([209.132.176.167]) by lo.gmane.org with esmtp (Exim 4.50) id 1Iq1WQ-0002Dc-SC for gcvg-git-2@gmane.org; Thu, 08 Nov 2007 08:09:51 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754041AbXKHHJf (ORCPT ); Thu, 8 Nov 2007 02:09:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754545AbXKHHJf (ORCPT ); Thu, 8 Nov 2007 02:09:35 -0500 Received: from sceptre.pobox.com ([207.106.133.20]:45901 "EHLO sceptre.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751552AbXKHHJe (ORCPT ); Thu, 8 Nov 2007 02:09:34 -0500 Received: from sceptre (localhost.localdomain [127.0.0.1]) by sceptre.pobox.com (Postfix) with ESMTP id 28F2D2EF; Thu, 8 Nov 2007 02:09:55 -0500 (EST) Received: from pobox.com (ip68-225-240-77.oc.oc.cox.net [68.225.240.77]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by sceptre.sasl.smtp.pobox.com (Postfix) with ESMTP id A60E8916C2; Thu, 8 Nov 2007 02:09:52 -0500 (EST) User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Sender: git-owner@vger.kernel.org Precedence: bulk X-Mailing-List: git@vger.kernel.org Archived-At: The 'automagic parseopt' support corrupted non option parameters that had IFS characters in them. The worst case can be seen when it has a non option parameter like this: $1=" * some string blech" Signed-off-by: Junio C Hamano --- * I had "git pull -n . to/pic-branch" in Meta/PU which was affected by this bug, expanding the " * " bullet before the merge message that is passed from git-pull to git-merge. I am a bit upset because I _knew_ that the eval was wrong when I first saw it, but somehow I forgot about it when I made it land on 'next'. My fault. git-sh-setup.sh | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/git-sh-setup.sh b/git-sh-setup.sh index e1cf885..f1c4839 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -21,11 +21,12 @@ if test -n "$OPTIONS_SPEC"; then exec "$0" -h } - parseopt_extra= - [ -n "$OPTIONS_KEEPDASHDASH" ] && - parseopt_extra="$parseopt_extra --keep-dashdash" - - eval `echo "$OPTIONS_SPEC" | git rev-parse --parseopt $parseopt_extra -- "$@" || echo exit $?` + [ -n "$OPTIONS_KEEPDASHDASH" ] && parseopt_extra="--keep-dashdash" + parsed=$( + echo "$OPTIONS_SPEC" | + git rev-parse --parseopt $parseopt_extra -- "$@" + ) && + eval "$parsed" || exit else usage() { die "Usage: $0 $USAGE" -- 1.5.3.5.1617.g65b5b