Re: using exec to close a fd in a var crashes bash
From:
Greg Wooledge
Subject:
Re: using exec to close a fd in a var crashes bash
Date:
Sat, 19 Aug 2023 16:49:12 -0400
On Sat, Aug 19, 2023 at 01:37:31PM -0400, jleivent wrote:
> Repeat-By:
>
> exec {foo}>/tmp/foo
> exec "${foo}"<&-
Remove the quotes and the $ and it should work.
exec {foo}<&-
The way you've got it is essentially:
exec "$foo" <&-
This does't make bash "crash". It's simply exec-ing a nonexistent
program.