1
0
Fork 0
mirror of synced 2024-12-21 14:11:08 -05:00

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:
Tim Byrne 2017-09-15 23:46:00 -05:00
parent b78bb1eef4
commit f23bdb8147
No known key found for this signature in database
GPG key ID: 14DB4FC2465A4B12
2 changed files with 1 additions and 78 deletions

View file

@ -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
View file

@ -35,7 +35,6 @@ FULL_COMMAND=""
GPG_PROGRAM="gpg"
GIT_PROGRAM="git"
LS_PROGRAM="/bin/ls"
ENVTPL_PROGRAM="envtpl"
LSB_RELEASE_PROGRAM="lsb_release"
@ -437,7 +436,6 @@ function encrypt() {
require_gpg
require_encrypt
require_ls
#; process relative to YADM_WORK
YADM_WORK=$(unix_path "$("$GIT_PROGRAM" config core.worktree)")
@ -473,7 +471,7 @@ function encrypt() {
#; report which files will be encrypted
echo "Encrypting the following files:"
"$LS_PROGRAM" -1 -d "${ENC_FILES[@]}"
printf '%s\n' "${ENC_FILES[@]}"
echo
#; encrypt all files which match the globs
@ -685,8 +683,6 @@ function list() {
function perms() {
require_ls
#; TODO: prevent repeats in the files changed
#; process relative to YADM_WORK
@ -1041,13 +1037,6 @@ function require_gpg() {
function require_repo() {
[ -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() {
[ -x "$SHELL" ] || error_out "\$SHELL does not refer to an executable."
}