[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] Why `$(<` is slow?
From: |
Stephane Chazelas |
Subject: |
Re: [Help-bash] Why `$(<` is slow? |
Date: |
Sat, 31 Aug 2019 10:55:12 +0100 |
User-agent: |
NeoMutt/20171215 |
2019-08-30 21:27:32 -0500, Peng Yu:
[...]
> > Bash parses the command and makes sure it's a valid redirection instead
> > of doing it lexically. That happens in the subshell just like any other
> > command substitution.
>
> Could you consider removing the overhead to make $(< lightweight like
> many other shells? Thanks.
[...]
I would second that.
Note that as noted at
https://unix.stackexchange.com/questions/189749/understanding-bashs-read-a-file-command-substitution/368663#368663
not forking has other implications like in
var=$(<"file$((++n))")
where the modification of $n is preserved.
I wouldn't expect changing the behaviour to have a negative
impact. If anything, that would improve compatibility with other
shells including the original implementation of that operator in
ksh.
It would be worth documenting that $(<...) is *not* command
substitution and doesn't involve a subshell (any longer in
bash after the change).
--
Stephane