What I observe in Yosemite, is that I have two different Bash scripts,and one AppleScript that work to toggle the hidden files, but if you copy/paste the identical defaults syntax from these scripts in the Terminal, it is ignored. A new Terminal session does not remedy this issue.
The syntax that I use matches yours, with the exception of -bool, and TRUE/FALSE usage. No variation of true/false appears to work in the Terminal. On Mavericks 10.9.5, with the patched Bash shell (v3.2.53(1) - same as Yosemite, these commands work just fine in the Terminal.
Here is some properly attributed AppleScript that you open in Script Editor, save as text (.AppleScript) to preserve the source, and then option + Save As… to an application (without app extension), and place in your Dock. Each time you click it, there is a transition from hidden to unhidden files. Called mine dothide.
This works equally well on Yosemite.
-- Submitted by Baltwo on Apple Support Community
try
do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
end try
if (do shell script "defaults read com.apple.finder AppleShowAllFiles") is equal to "0" then
do shell script "defaults write com.apple.finder AppleShowAllFiles 1"
else
do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
end if
do shell script "killall Finder"