Years ago, I added a function to my .bashrc that looks like this: `bat () { echo "$(<"$@")" ; }`. Now that I'm back on Linux with a new installation (different distro), I get an error that says `bash: "$@": ambiguous redirect` when I try to use it. I'm confused about what I meant to do. Any insights?
2 Answers
It seems like the function was meant to read and display multiple files, but it isn't working quite right. The issue is that your implementation might only handle a single argument correctly.
Your original intention seems to be trying to mimic `cat` with just Bash builtins, but this function only works with one argument. If you want to handle multiple files, try this instead:
`bat() { local f; for f in "$@"; do echo "$(<"$f")"; done; }`. That should echo the contents of each file one after the other!

Haha, that’s a solid fix! Now if only it could also handle stdin like `cat` does!