Skip to content

Commit

Permalink
Switch back interpreter to POSIX sh
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Dec 2, 2021
1 parent 359c996 commit 9f04dbe
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#### Changed
- Switch to semver for versioning
- Wrap rsync into eval to escape paths
- Switch to bash interpreter for printf "%q"

#### Added
- CI: check for special chars in file names
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ lint-shell:
@echo "# -------------------------------------------------------------------- #"
@echo "# Lint shellcheck #"
@echo "# -------------------------------------------------------------------- #"
@docker run --rm -v $(PWD):/mnt koalaman/shellcheck:stable --shell=bash timemachine
@docker run --rm -v $(PWD):/mnt koalaman/shellcheck:stable --shell=sh timemachine


test: test-local-default-abs-noslash-noslash
Expand Down
45 changes: 1 addition & 44 deletions timemachine
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash -eu

set -o pipefail
#!/bin/sh -eu
#
# https://serverfault.com/questions/834994/rsync-only-keep-10-backup-folders
export PATH=/bin:/usr/bin
Expand Down Expand Up @@ -133,23 +131,10 @@ logerr() {
# Backup Functions
################################################################################

# https://stackoverflow.com/questions/1167746/how-to-assign-a-heredoc-value-to-a-variable-in-bash
#define() {
# o=;
# while IFS="\n" read -r a; do
# o="$o$a"'
# ';
# done;
# eval "$1=\$o";
#}

###
### POSIX compliant path escape (like printf "%q" in bash)
###
escape_path() {
# bash version
printf "%q" "${1}"
return
# POSIX version
# https://mullikine.github.io/posts/missing-posix-shell-functions-cmd-and-myeval/
for var in "${@}"; do
Expand All @@ -158,13 +143,6 @@ escape_path() {
done | sed 's/ $//'
}

###
### Ensure to remove single quotes from start and end
###
unquote_path() {
echo "${1}" | sed "s/^'//g" | sed "s/'\$//g"
}

###
### Check if the destination is a remote server
###
Expand Down Expand Up @@ -239,27 +217,6 @@ link_exists() {
fi
}

###
### Remove local or remote file
###
#remove_file() {
# file="${1}"
#
# logdebug "Removing file: ${1}"
# if is_remote "${file}"; then
# ssh_part="$( echo "${file}" | awk -F':' '{print $1}' )"
# file_part="$( echo "${file}" | awk -F':' '{print $2}' )"
# file_part="$( escape_path "${file_part}" )"
# ssh_cmd="rm ${file_part}"
# cmd="ssh ${SSH_ARGS} ${ssh_part} ${ssh_cmd}"
# else
# file="$( escape_path "${file}" )"
# cmd="rm ${file}"
# fi
# logdebug "\$ ${cmd}"
# eval "${cmd}" >/dev/null
#}

###
### Rename local or remote directory
###
Expand Down

0 comments on commit 9f04dbe

Please sign in to comment.