This is an excerpt from a script I am writing to modify some configuration options in a file:
Code:
I'm getting this error: ./backup.sh: line 45: [: : unary operator expected
Line 45 is the one asterisked in this code.
The idea of the == "" statements is to have a blank input mean inherit old value. Anyone help?
Code:
"config" )
full=$FULL_BACKUP
includedir=$INCLUDE_DIRS
excludedir=$EXCLUDE_DIRS
keeplocal=$KEEP_LOCAL_BACKUPS
localdir=$LOCAL_BACKUP_DIR
echo "Starting configuration mode for backup.sh..."
echo "Input the information requested. To leave a setting as is, simply leave it blank."
echo "Do you want to take full backups of your system? Doing this will create a more complete backup, but will also take longer and will occupy more disk space on your computer and the remote server? Input 1 to take full backups, or 0 if you want to specify what folders to back up."
echo "Current Value: $full"
read $style
if [ "$style" == "" ]; then
style=$full
fi
FULL_BACKUP=$style
if [ "$style" == "0" ]; then
echo "Specify a list of folders to backup, separated by spaces (Ex: \"/Users/joe /etc /var\")."
echo "Current Value: $includedir"
read $include
*** if [ "$include" == ""]; then
include=$includedir
fi
INCLUDE_DIRS=$include
fi
echo "Specify a list of folders to never backup, separated by spaces (Ex: \"/Users/joe /etc /var\"). The backup dir will be added automatically."
echo "Current Value: $excludedir"
read $exclude
if [ "$exclude" == "" ]; then
exclude=$excludedir
fi
EXCLUDE_DIRS=$exclude
echo "Do you want to save compressed backups on your own computer or delete them upon completion? Input 1 to save backups, 0 to delete them."
echo "Current Value: $keeplocal"
read $keep
if [ "$keep" == "" ]; then
keep=$keeplocal
fi
KEEP_LOCAL_BACKUPS=$keep
echo "Where on your computer will we save the compressed backup to?"
echo "Current Value: $localdir"
read $dir
if [ "$dir" == "" ]; then
dir=$localdir
fi
LOCAL_BACKUP_DIR=$dir
echo "FULL_BACKUP=$FULL_BACKUP" > backup.conf
echo "INCLUDE_DIRS=$INCLUDE_DIRS" >> backup.conf
EXCLUDE_DIRS="$LOCAL_BACKUP_DIR $EXCLUDE_DIRS"
echo "EXCLUDE_DIRS=$EXCLUDE_DIRS" >> backup.conf
echo "KEEP_LOCAL_BACKUPS=$KEEP_LOCAL_BACKUPS" >> backup.conf
echo "LOCAL_BACKUP_DIR=$LOCAL_BACKUP_DIR" >> backup.conf
echo "Configuration updated! New settings:"
echo "Full Backups: $FULL_BACKUP"
echo "Included Dirs (for Full Backup = 0): $INCLUDE_DIRS"
echo "Exluded Dirs: $EXCLUDE_DIRS"
echo "Keep Local Backups: $KEEP_LOCAL_BACKUPS"
echo "Local Backup Dir: $LOCAL_BACKUP_DIR"
;;
I'm getting this error: ./backup.sh: line 45: [: : unary operator expected
Line 45 is the one asterisked in this code.
The idea of the == "" statements is to have a blank input mean inherit old value. Anyone help?