I've created a little rsync script to sync my podcasts. I've configured the script to email me when it's done. I am attempting to test rsync's exit status to decide which message gets sent. Here is the block:
my_command= rsync --log-file=/home/jake/logs/rsync.log -avzu $local_directory $remote_directory
if [ $? -eq 0 ]; then
$mail_expression_success
else
$mail_expression_fail
fi
No matter how the command finishes I get the message contained in the first variable. $mail_expression_success.
my_commandis unused).my_command="rsync..."is intended, then it really is a variable assignment which always succeeds, althoughrsyncis never actually called. If the intention is to capture the output ofrsyncwithmy_command=$(rsync ...), thenrsyncis called, but instead of assigning the output tomy_command,rsyncis simply run in an environment wheremy_commandis null valued (and ignored byrsync). In the latter case, it does seem, as William Pursell points out, thatrsyncis simply succeeding.