Browse Source

Standardize on &> when not appending output

pull/194/head
Tim Byrne 2 years ago
parent
commit
4d23bbcf11
No known key found for this signature in database GPG Key ID: 14DB4FC2465A4B12
  1. 4
      Makefile
  2. 4
      bootstrap
  3. 30
      yadm

4
Makefile

@ -92,7 +92,7 @@ test:
cd /yadm && \
py.test -v $(testargs); \
else \
if command -v "docker-compose" >/dev/null 2>&1; then \
if command -v "docker-compose" &> /dev/null; then \
docker-compose run --rm testbed make test testargs="$(testargs)"; \
else \
echo "Sorry, this make test requires docker-compose to be installed."; \
@ -192,7 +192,7 @@ sync-clock:
.PHONY: require-docker
require-docker:
@if ! command -v "docker" >/dev/null 2>&1; then \
@if ! command -v "docker" &> /dev/null; then \
echo "Sorry, this make target requires docker to be installed."; \
false; \
fi

4
bootstrap

@ -35,7 +35,7 @@ REPO_URL=""
function _private_yadm() {
unset -f yadm
if command -v yadm >/dev/null 2>&1; then
if command -v yadm &> /dev/null; then
echo "Found yadm installed locally, removing remote yadm() function"
unset -f _private_yadm
command yadm "$@"
@ -57,7 +57,7 @@ function remote_yadm() {
}
function ask_about_source() {
if ! command -v yadm >/dev/null 2>&1; then
if ! command -v yadm &> /dev/null; then
echo
echo "***************************************************"
echo "yadm is NOT currently installed."

30
yadm

@ -1110,7 +1110,7 @@ function perms() {
# remove group/other permissions from collected globs
#shellcheck disable=SC2068
#(SC2068 is disabled because in this case, we desire globbing)
chmod -f go-rwx ${GLOBS[@]} >/dev/null 2>&1
chmod -f go-rwx ${GLOBS[@]} &> /dev/null
# TODO: detect and report changing permissions in a portable way
}
@ -1159,7 +1159,7 @@ function upgrade() {
echo "Moving $legacy_path to $new_filename"
assert_parent "$new_filename"
# test to see if path is "tracked" in repo, if so 'git mv' must be used
if "$GIT_PROGRAM" ls-files --error-unmatch "$legacy_path" >/dev/null 2>&1; then
if "$GIT_PROGRAM" ls-files --error-unmatch "$legacy_path" &> /dev/null; then
"$GIT_PROGRAM" mv "$legacy_path" "$new_filename" && repo_updates=1
else
mv -i "$legacy_path" "$new_filename"
@ -1170,7 +1170,7 @@ function upgrade() {
# handle submodules, which need to be reinitialized
if [ "$actions_performed" -ne 0 ]; then
cd_work "Upgrade submodules"
if "$GIT_PROGRAM" ls-files --error-unmatch .gitmodules >/dev/null 2>&1; then
if "$GIT_PROGRAM" ls-files --error-unmatch .gitmodules &> /dev/null; then
"$GIT_PROGRAM" submodule deinit -f .
"$GIT_PROGRAM" submodule update --init --recursive
fi
@ -1256,7 +1256,7 @@ function is_valid_branch_name() {
function query_distro() {
distro=""
if command -v "$LSB_RELEASE_PROGRAM" >/dev/null 2>&1; then
if command -v "$LSB_RELEASE_PROGRAM" &> /dev/null; then
distro=$($LSB_RELEASE_PROGRAM -si 2>/dev/null)
elif [ -f "$OS_RELEASE" ]; then
while IFS='' read -r line || [ -n "$line" ]; do
@ -1493,7 +1493,7 @@ function set_operating_system() {
function set_awk() {
local pgm
for pgm in "${AWK_PROGRAM[@]}"; do
command -v "$pgm" >/dev/null 2>&1 && AWK_PROGRAM=("$pgm") && return
command -v "$pgm" &> /dev/null && AWK_PROGRAM=("$pgm") && return
done
}
@ -1559,7 +1559,7 @@ function assert_private_dirs() {
if [ ! -d "$work/$private_dir" ]; then
debug "Creating $work/$private_dir"
#shellcheck disable=SC2174
mkdir -m 0700 -p "$work/$private_dir" >/dev/null 2>&1
mkdir -m 0700 -p "$work/$private_dir" &> /dev/null
fi
done
}
@ -1603,10 +1603,10 @@ function parse_encrypt() {
# setting globstar to allow ** in encrypt patterns
# (only supported on Bash >= 4)
local unset_globstar
if ! shopt globstar &>/dev/null; then
if ! shopt globstar &> /dev/null; then
unset_globstar=1
fi
shopt -s globstar &>/dev/null
shopt -s globstar &> /dev/null
exclude_pattern="^!(.+)"
if [ -f "$YADM_ENCRYPT" ] ; then
@ -1652,7 +1652,7 @@ function parse_encrypt() {
fi
if [ "$unset_globstar" = "1" ]; then
shopt -u globstar &>/dev/null
shopt -u globstar &> /dev/null
fi
}
@ -1781,7 +1781,7 @@ function require_git() {
GIT_PROGRAM="$alt_git"
more_info="\nThis command has been set via the yadm.git-program configuration."
fi
command -v "$GIT_PROGRAM" >/dev/null 2>&1 ||
command -v "$GIT_PROGRAM" &> /dev/null ||
error_out "This functionality requires Git to be installed, but the command '$GIT_PROGRAM' cannot be located.$more_info"
}
function require_gpg() {
@ -1795,7 +1795,7 @@ function require_gpg() {
GPG_PROGRAM="$alt_gpg"
more_info="\nThis command has been set via the yadm.gpg-program configuration."
fi
command -v "$GPG_PROGRAM" >/dev/null 2>&1 ||
command -v "$GPG_PROGRAM" &> /dev/null ||
error_out "This functionality requires GPG to be installed, but the command '$GPG_PROGRAM' cannot be located.$more_info"
}
function require_repo() {
@ -1809,19 +1809,19 @@ function bootstrap_available() {
return 1
}
function awk_available() {
command -v "${AWK_PROGRAM[0]}" >/dev/null 2>&1 && return
command -v "${AWK_PROGRAM[0]}" &> /dev/null && return
return 1
}
function j2cli_available() {
command -v "$J2CLI_PROGRAM" >/dev/null 2>&1 && return
command -v "$J2CLI_PROGRAM" &> /dev/null && return
return 1
}
function envtpl_available() {
command -v "$ENVTPL_PROGRAM" >/dev/null 2>&1 && return
command -v "$ENVTPL_PROGRAM" &> /dev/null && return
return 1
}
function readlink_available() {
command -v "readlink" >/dev/null 2>&1 && return
command -v "readlink" &> /dev/null && return
return 1
}

Loading…
Cancel
Save