This one's driving me NUTS. Any help appreciated!
$MYSQLDUMP --login-path=$HOST $DATABASE > "$BACKUP_DIR/${HOST}__${DATABASE}__${NOW}.sql";  - I've confirmed that the binary 
$MYSQLDUMP(within the script) has a valid full path - The command is complete (confirmed via echo)
 $NOWis set early on in the script, and not here...so the time isn't changing on us or anything- This is not being run via cron
 - The user executing the script via command line, also has access/permissions to the actual directory
 - Tried 
dos2unixto ensure no weird characters. I'm on a Mac, but hey...why not - Attempted to escape the 
>like\>, which instead produces amysqldump: Couldn't find table: ">"error 
This one's driving me crazy. Not sure what I'm missing here? We're just directing output, and I feel like it's something ridiculously obvious I'm overlooking.
UPDATE
Added some more tests to debug and assist here.
vrb "\$BACKUP_DIR: $BACKUP_DIR" vrb "whoami $(whoami)" vrb "ls -ld \"$BACKUP_DIR/\" $(ls -ld \"$BACKUP_DIR/\")" vrb "absolute path of user's home dir: $(cd ~/; pwd)" vrb "absolute path of \$BACKUP_DIR: $(cd $BACKUP_DIR/; pwd)"  ...produces...
20160713T210808Z: $BACKUP_DIR: ~/www/__MYSQL/backup 20160713T210808Z: whoami william ls: "~/www/__MYSQL/backup/": No such file or directory 20160713T210808Z: ls -ld "~/www/__MYSQL/backup/" 20160713T210808Z: absolute path of user's home dir: /Users/william ./mygration.sh: line 383: cd: ~/www/__MYSQL/backup/: No such file or directory 20160713T210808Z: absolute path of $BACKUP_DIR: >> ERROR: 1  vrb is just another function that processes verbose output in the script, so don't be alarmed by that. It's only for outputting the debugged info.
If I manually list the contents in the same terminal to ~/www/__MYSQL/backup/, I can see the following:
$ ls -la ~/www/__MYSQL/backup/ total 0 drwxr-xr-x 2 william staff 68 Jul 13 20:55 . drwxr-xr-x 6 william staff 204 Jul 13 20:55 ..  It's weird. Almost like Bash doesn't have access, but my regular user (the one running the bash script in the first place) does.
ANOTHER UPDATE
echo $(whoami); echo ~; exit;  ...produces...
william /Users/william  
ls -ld ~/www/__MYSQL/backup/which could perhaps give us clues as the situation is getting weirder.