Update backup_*
This commit is contained in:
parent
41f13f65d3
commit
3924fba938
|
@ -4,14 +4,14 @@
|
||||||
############################### completion start ###############################
|
############################### completion start ###############################
|
||||||
options='--no-chattr --no-sudo'
|
options='--no-chattr --no-sudo'
|
||||||
if [ -n "${COMP_LINE}" ] ; then
|
if [ -n "${COMP_LINE}" ] ; then
|
||||||
if [ "${1}" = "${3}" ] && [ ! "${2#-}" = "${2}" ] ; then
|
if [ "${2#-}" = "${2}" ] ; then
|
||||||
|
find "$(dirname -- "${2}")" -mindepth 1 -maxdepth 1 -path "$(dirname -- "${2}")/$(basename -- "${2}")*"
|
||||||
|
else
|
||||||
for option in $options ; do
|
for option in $options ; do
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
"${2}"*) printf '%s\n' "${option}" ;;
|
"${2}"*) printf '%s\n' "${option}" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
elif [ "${2#-}" = "${2}" ] ; then
|
|
||||||
find "$(dirname -- "${2}")" -mindepth 1 -maxdepth 1 -path "$(dirname -- "${2}")/$(basename -- "${2}")*"
|
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -30,10 +30,16 @@ while : ; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
test "${#}" -ne "2" && { log.err "Usage: backup_dir [--no-chattr] [--no-sudo] BACKUP_DIR DIR" ; exit 1 ; }
|
if [ "${#}" -eq "1" ] && [ -n "${1}" ]; then
|
||||||
|
backupdir="${HOME}/backups"
|
||||||
backupdir="${1:-${HOME}/backups}"
|
srcdir="${1}"
|
||||||
srcdir="${2}"
|
elif [ "${#}" -eq "2" ] && [ -n "${1}" ] && [ -n "${2}" ] ; then
|
||||||
|
backupdir="${1}"
|
||||||
|
srcdir="${2}"
|
||||||
|
else
|
||||||
|
log.err "Usage: backup_dir [--no-chattr] [--no-sudo] [BACKUP_DIR] DIR"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
############################# argument parsing end #############################
|
############################# argument parsing end #############################
|
||||||
|
|
||||||
if [ "${no_sudo}" = "1" ] ; then
|
if [ "${no_sudo}" = "1" ] ; then
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
############################### completion start ###############################
|
############################### completion start ###############################
|
||||||
options='--no-chattr --no-sudo'
|
options='--no-chattr --no-sudo'
|
||||||
if [ -n "${COMP_LINE}" ] ; then
|
if [ -n "${COMP_LINE}" ] ; then
|
||||||
if [ "${1}" = "${3}" ] && [ ! "${2#-}" = "${2}" ] ; then
|
if [ "${2#-}" = "${2}" ] ; then
|
||||||
|
find "$(dirname -- "${2}")" -mindepth 1 -maxdepth 1 -path "$(dirname -- "${2}")/$(basename -- "${2}")*"
|
||||||
|
else
|
||||||
for option in $options ; do
|
for option in $options ; do
|
||||||
case "${option}" in
|
case "${option}" in
|
||||||
"${2}"*) printf '%s\n' "${option}" ;;
|
"${2}"*) printf '%s\n' "${option}" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
elif [ "${2#-}" = "${2}" ] ; then
|
|
||||||
find "$(dirname -- "${2}")" -mindepth 1 -maxdepth 1 -path "$(dirname -- "${2}")/$(basename -- "${2}")*"
|
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -30,10 +30,16 @@ while : ; do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
test "${#}" -ne "2" && { log.err "Usage: backup_dir [--no-chattr] [--no-sudo] BACKUP_DIR DIR" ; exit 1 ; }
|
if [ "${#}" -eq "1" ] && [ -n "${1}" ]; then
|
||||||
|
backupdir="${HOME}/backups"
|
||||||
backupdir="${1:-${HOME}/backups}"
|
srcfile="${1}"
|
||||||
srcfile="${2}"
|
elif [ "${#}" -eq "2" ] && [ -n "${1}" ] && [ -n "${2}" ] ; then
|
||||||
|
backupdir="${1}"
|
||||||
|
srcfile="${2}"
|
||||||
|
else
|
||||||
|
log.err "Usage: backup_dir [--no-chattr] [--no-sudo] [BACKUP_DIR] FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
############################# argument parsing end #############################
|
############################# argument parsing end #############################
|
||||||
|
|
||||||
if [ "${no_sudo}" = "1" ] ; then
|
if [ "${no_sudo}" = "1" ] ; then
|
||||||
|
|
Loading…
Reference in New Issue