Remove last use of LS_PROGRAM
Globs are not determined by an `eval` of `ls` anymore. The only other use of `ls` can be replaced with a simple `printf`.
This commit is contained in:
parent
b78bb1eef4
commit
f23bdb8147
2 changed files with 1 additions and 78 deletions
|
@ -1,66 +0,0 @@
|
||||||
load common
|
|
||||||
load_fixtures
|
|
||||||
|
|
||||||
@test "Default /bin/ls" {
|
|
||||||
echo "
|
|
||||||
By default, the value of LS_PROGRAM should be /bin/ls
|
|
||||||
"
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
YADM_TEST=1 source "$T_YADM"
|
|
||||||
status=0
|
|
||||||
output=$( require_ls; echo "$LS_PROGRAM" ) || {
|
|
||||||
status=$?
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "output=$output"
|
|
||||||
|
|
||||||
[ "$status" == 0 ]
|
|
||||||
[ "$output" = "/bin/ls" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "Fallback on 'ls'" {
|
|
||||||
echo "
|
|
||||||
When LS_PROGRAM doesn't exist, use 'ls'
|
|
||||||
"
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
YADM_TEST=1 source "$T_YADM"
|
|
||||||
status=0
|
|
||||||
LS_PROGRAM="/ls/missing"
|
|
||||||
output=$( require_ls; echo "$LS_PROGRAM" ) || {
|
|
||||||
status=$?
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "output=$output"
|
|
||||||
|
|
||||||
[ "$status" == 0 ]
|
|
||||||
[ "$output" = "ls" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "Fail if ls isn't in PATH" {
|
|
||||||
echo "
|
|
||||||
When LS_PROGRAM doesn't exist, use 'ls'
|
|
||||||
"
|
|
||||||
|
|
||||||
# shellcheck source=/dev/null
|
|
||||||
YADM_TEST=1 source "$T_YADM"
|
|
||||||
status=0
|
|
||||||
LS_PROGRAM="/ls/missing"
|
|
||||||
savepath="$PATH"
|
|
||||||
# shellcheck disable=SC2123
|
|
||||||
PATH=
|
|
||||||
output=$( require_ls 2>&1; echo "$LS_PROGRAM" ) || {
|
|
||||||
status=$?
|
|
||||||
true
|
|
||||||
}
|
|
||||||
PATH="$savepath"
|
|
||||||
|
|
||||||
echo "output=$output"
|
|
||||||
|
|
||||||
[ "$status" != 0 ]
|
|
||||||
[[ "$output" =~ functionality\ requires\ .ls.\ to\ be\ installed ]]
|
|
||||||
}
|
|
||||||
|
|
13
yadm
13
yadm
|
@ -35,7 +35,6 @@ FULL_COMMAND=""
|
||||||
|
|
||||||
GPG_PROGRAM="gpg"
|
GPG_PROGRAM="gpg"
|
||||||
GIT_PROGRAM="git"
|
GIT_PROGRAM="git"
|
||||||
LS_PROGRAM="/bin/ls"
|
|
||||||
ENVTPL_PROGRAM="envtpl"
|
ENVTPL_PROGRAM="envtpl"
|
||||||
LSB_RELEASE_PROGRAM="lsb_release"
|
LSB_RELEASE_PROGRAM="lsb_release"
|
||||||
|
|
||||||
|
@ -437,7 +436,6 @@ function encrypt() {
|
||||||
|
|
||||||
require_gpg
|
require_gpg
|
||||||
require_encrypt
|
require_encrypt
|
||||||
require_ls
|
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
#; process relative to YADM_WORK
|
||||||
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
|
||||||
|
@ -473,7 +471,7 @@ function encrypt() {
|
||||||
|
|
||||||
#; report which files will be encrypted
|
#; report which files will be encrypted
|
||||||
echo "Encrypting the following files:"
|
echo "Encrypting the following files:"
|
||||||
"$LS_PROGRAM" -1 -d "${ENC_FILES[@]}"
|
printf '%s\n' "${ENC_FILES[@]}"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
#; encrypt all files which match the globs
|
#; encrypt all files which match the globs
|
||||||
|
@ -685,8 +683,6 @@ function list() {
|
||||||
|
|
||||||
function perms() {
|
function perms() {
|
||||||
|
|
||||||
require_ls
|
|
||||||
|
|
||||||
#; TODO: prevent repeats in the files changed
|
#; TODO: prevent repeats in the files changed
|
||||||
|
|
||||||
#; process relative to YADM_WORK
|
#; process relative to YADM_WORK
|
||||||
|
@ -1041,13 +1037,6 @@ function require_gpg() {
|
||||||
function require_repo() {
|
function require_repo() {
|
||||||
[ -d "$YADM_REPO" ] || error_out "Git repo does not exist. did you forget to run 'init' or 'clone'?"
|
[ -d "$YADM_REPO" ] || error_out "Git repo does not exist. did you forget to run 'init' or 'clone'?"
|
||||||
}
|
}
|
||||||
function require_ls() {
|
|
||||||
if [ ! -f "$LS_PROGRAM" ] ; then
|
|
||||||
command -v ls >/dev/null 2>&1 || \
|
|
||||||
error_out "This functionality requires 'ls' to be installed at '$LS_PROGRAM' or listed in your \$PATH"
|
|
||||||
LS_PROGRAM=ls
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function require_shell() {
|
function require_shell() {
|
||||||
[ -x "$SHELL" ] || error_out "\$SHELL does not refer to an executable."
|
[ -x "$SHELL" ] || error_out "\$SHELL does not refer to an executable."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue