From: Jeff King Date: Tue, 18 Jun 2019 17:04:16 GMT Subject: Re: [PATCH v2 01/10] t: add helper to convert object IDs to paths Message-ID: <20190618170416.GA14636@sigill.intra.peff.net> In-Reply-To: On Tue, Jun 18, 2019 at 06:15:46PM +0200, Johannes Schindelin wrote: > > And looking through this patch series, I see a gazillion of *new* > > process substitutions $(test_something...) and $(basename $whatever). > > Can't we do something about it? > > I wish there was. Unix shell scripting has not evolved much in the past, > what, 3 decades? So I don't really see a way to "pass variables by > reference" to shell functions, short of calling `eval` (which buys > preciously little as it _also_ has to spawn a new process [*1*]). Really? An eval can impact the caller's state, so it _can't_ happen in a sub-process in most cases. E.g., if I run this: -- >8 -- #!/bin/sh # usage: test_oid_to_path # to set the variable in the caller's environment to the path of test_oid_to_path() { path="${2%${2#??}}/${2#??}" eval "$1=\$path" } test_oid_to_path foo 1234abcd echo foo: $foo -- >8 -- it all happens in a single process, under both bash and dash. -Peff