演示我的问题的示例 bash 脚本:
#!/bin/bash
function exclude
{
BACKUP_EXCLUDES="$BACKUP_EXCLUDES --exclude=\"$1\""
}
exclude "/proc"
exclude "/dev"
exclude "/mnt"
exclude "/media"
exclude "/lost+found"
echo $BACKUP_EXCLUDES
输出:
--exclude="/proc" --exclude="/dev" --exclude="/mnt" --exclude="/media" --exclude="/lost+found"
完美的!但是当我尝试添加时:
rsync -ruvz $BACKUP_EXCLUDES / /some/backup/path
$BACKUP_EXCLUDES 被完全忽略,没有错误或警告......为什么?