I have read this Q&A, but it seems to always think the parameter as file.
I want to transform the command diff <(ls old) <(ls new)
from this link to one function which receive two arguments, although it is somewhat redundant.
I tried this which is just arg replace:
d2c(){
diff <($1) <($2)
}
then run d2c "objdump -d foo1" "objdump -d foo2"
show d2c:1: no such file or directory: objdump -d foo1
with fifo , above problem still be there.
Q: How can I pass arg like '"objdump -d foo1"', then let it run as command?
eval
:d2c () { diff <(eval "$1") <(eval "$2"); }
, but if you're on zsh, you can also tryd2c () diff <(${(z)1}) <(${(z)2})
– muru Jun 06 '23 at 11:55Q
(to remove quotes) and@
within quotes to preserve empty elements in addition to thatz
tokenisation flag, but that would mean one could only run simple commands so would have no advantage overeval
. – Stéphane Chazelas Jun 06 '23 at 12:02eval "$1"
works for me. – An5Drama Jun 06 '23 at 12:36$1
, but that's not the default in bash, where it is in zsh. – muru Jun 06 '23 at 13:19