-
Notifications
You must be signed in to change notification settings - Fork 1.9k
bash: cat in variable assignment -> redirect? #2493
Copy link
Copy link
Open
Description
For new checks and feature suggestions
- https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
- I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related
While reading through the bash manual I encountered this:
The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).
It's a relatively minor thing but it might be worth suggesting to users.
Thoughts?
Here's a snippet or screenshot that shows the problem:
#!/bin/bash
var=$(cat file.txt)Here's what shellcheck currently says:
n/a
Here's what I wanted or expected to see:
Suggestion to use var=$(< file.txt) instead
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels