# [PATCH] shell: add missing initialization of argv0_path

3 messages from 2011-05-05 to 2011-05-05. Participants: Dima Sharov, Johannes Sixt, Junio C Hamano.
Thread: https://gitlist.dev/t/27260

## Dima Sharov, 2011-05-05 06:40

Subject: [PATCH] shell: add missing initialization of argv0_path
Message-ID: <62D8CA91-5C11-458E-AADB-D8EC8EB99F09@gmail.com>
URL: https://gitlist.dev/e/62D8CA91-5C11-458E-AADB-D8EC8EB99F09%40gmail.com

```
According to c6dfb39 (remote-curl: add missing initialization of
argv0_path, 2009-10-13), stand-alone programs (non-builtins)
must call git_extract_argv0_path(argv[0]) in order to help builds
that derive the installation prefix at runtime. Without this call,
the program segfaults (or raises an assertion failure).

Signed-off-by: Dima Sharov <git.avalakvista@gmail.com>
---
shell.c |    2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/shell.c b/shell.c
index dea4cfd..abb8622 100644
--- a/shell.c
+++ b/shell.c
@@ -137,6 +137,8 @@ int main(int argc, char **argv)
	int devnull_fd;
	int count;

+	git_extract_argv0_path(argv[0]);
+
	/*
	 * Always open file descriptors 0/1/2 to avoid clobbering files
	 * in die().  It also avoids not messing up when the pipes are
-- 
1.7.2.3

```

## Johannes Sixt, 2011-05-05 06:58

Subject: Re: [PATCH] shell: add missing initialization of argv0_path
Message-ID: <4DC24A7F.20705@viscovery.net>
URL: https://gitlist.dev/e/4DC24A7F.20705%40viscovery.net
In-Reply-To: <62D8CA91-5C11-458E-AADB-D8EC8EB99F09@gmail.com>

```
Am 5/5/2011 8:40, schrieb Dima Sharov:
> According to c6dfb39 (remote-curl: add missing initialization of
> argv0_path, 2009-10-13), stand-alone programs (non-builtins)
> must call git_extract_argv0_path(argv[0]) in order to help builds
> that derive the installation prefix at runtime. Without this call,
> the program segfaults (or raises an assertion failure).

Good catch! I checked PROGRAM_OBJS in Makefile, and shell.c was the only
one remaining that did not call this function.

-- Hannes

```

## Junio C Hamano, 2011-05-05 16:32

Subject: Re: [PATCH] shell: add missing initialization of argv0_path
Message-ID: <7vmxj19kgf.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vmxj19kgf.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4DC24A7F.20705@viscovery.net>

```
Johannes Sixt <j.sixt@viscovery.net> writes:

> Am 5/5/2011 8:40, schrieb Dima Sharov:
>> According to c6dfb39 (remote-curl: add missing initialization of
>> argv0_path, 2009-10-13), stand-alone programs (non-builtins)
>> must call git_extract_argv0_path(argv[0]) in order to help builds
>> that derive the installation prefix at runtime. Without this call,
>> the program segfaults (or raises an assertion failure).
>
> Good catch! I checked PROGRAM_OBJS in Makefile, and shell.c was the only
> one remaining that did not call this function.

Thanks for an Ack; the patch was corrupt but was trivial to fix-up.
Will queue.

```
