summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVon Random <von@mechanus.net>2015-02-18 18:59:23 +0300
committerVon Random <von@mechanus.net>2015-02-18 18:59:23 +0300
commitf515160bd643c9e79426c08623b700ac0d22ae22 (patch)
tree0893bc6a4481f7e26b6f7bb75cf20468641f7164
parentd7ec2ce02f58676a92c0f7bda66b15bfaeca56a4 (diff)
swap some string tests to math tests
-rwxr-xr-xbackup.zsh8
1 files changed, 4 insertions, 4 deletions
diff --git a/backup.zsh b/backup.zsh
index 074d40d..6022da3 100755
--- a/backup.zsh
+++ b/backup.zsh
@@ -47,7 +47,7 @@ function apply_config
cfg_err 'remote_pass'
return 5
fi
- if [[ -n $port && ! $port =~ ^[0-9]+$ ]]; then
+ if ! (( port )); then
err 'remote_port is not a numeric value.'
return 5
fi
@@ -64,8 +64,8 @@ function apply_config
# set defaults and / or fail to run if something is missing
local exit_code
case $protocol in
- ('ftp'|'ftps') port=${remote_port:-$default_ftp_port}; test_remote_settings; exit_code=$?; [[ $exit_code -ne 0 ]] && return $exit_code;;
- ('sftp'|'ssh') port=${remote_port:-$default_ssh_port}; test_remote_settings; exit_code=$?; [[ $exit_code -ne 0 ]] && return $exit_code;;
+ ('ftp'|'ftps') port=${remote_port:-$default_ftp_port}; test_remote_settings; exit_code=$?; (( exit_code )) && return $exit_code;;
+ ('sftp'|'ssh') port=${remote_port:-$default_ssh_port}; test_remote_settings; exit_code=$?; (( exit_code )) && return $exit_code;;
('local') unset remote_port;;
(*) cfg_err 'protocol'; return 5;;
esac
@@ -159,7 +159,7 @@ function main
apply_config
# fail in case something goes wrong
local exit_code=$?
- [[ $exit_code -ne 0 ]] && return $exit_code
+ (( exit_code )) && return $exit_code
unset exit_code
# run backups per directory
for i in $source_dirs; do