From f23bdb8147eb000e977b91d134f355685adf1662 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Fri, 15 Sep 2017 23:46:00 -0500 Subject: [PATCH] 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`. --- test/003_unit_ls_program.bats | 66 ----------------------------------- yadm | 13 +------ 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100644 test/003_unit_ls_program.bats diff --git a/test/003_unit_ls_program.bats b/test/003_unit_ls_program.bats deleted file mode 100644 index 7d57099..0000000 --- a/test/003_unit_ls_program.bats +++ /dev/null @@ -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 ]] -} - diff --git a/yadm b/yadm index cb4dcfa..c55eea6 100755 --- a/yadm +++ b/yadm @@ -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." }