I noticed the issue when I first went to run
defaults write com.apple.finder AppleShowAllFiles YES
in macOS terminal (10.11.2) but this was returned
bash: /usr/bin/defaults: Invalid argument
I'm not sure what is going on with defaults, but I also have a similar issue with brew:
/bin/bash: /usr/bin/dirname: Invalid argument
I clearly broke something, but not sure how I did it or when it happened. This is causing all sorts of issues. Any thoughts on fixing it?
I reinstalled El Capitan from the recovery partition (restart holding command-R), and it solved the issue. My guess is that the xcode command tools were to blame.