Fixes to binary finding
This commit is contained in:
		| @@ -35,7 +35,7 @@ while true; do | |||||||
| done | done | ||||||
|  |  | ||||||
| # check for existence of fd and fzf binaries | # check for existence of fd and fzf binaries | ||||||
| if [[ ! -x '/usr/bin/fzf' ]]; then | if ! $(which fzf > /dev/null); then | ||||||
|     printf '%s\n' 'fzf is not installed on the system' |     printf '%s\n' 'fzf is not installed on the system' | ||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
| @@ -43,13 +43,13 @@ fi | |||||||
| declare -a find_opts | declare -a find_opts | ||||||
| template_dir="${HOME}/Templates" | template_dir="${HOME}/Templates" | ||||||
|  |  | ||||||
| if [[ -x '/usr/bin/fd' ]]; then | if [[ -x $(which fd) ]]; then | ||||||
|     find_bin='/usr/bin/fd' |     find_bin=$(which fd) | ||||||
|     find_opts+=('--print0') |     find_opts+=('--print0') | ||||||
|     find_opts+=('--type' 'f') |     find_opts+=('--type' 'f') | ||||||
|     find_opts+=('.' "${template_dir}") |     find_opts+=('--' '.' "${template_dir}") | ||||||
| else | else | ||||||
|     find_bin='/usr/bin/find' |     find_bin=$(which find) | ||||||
|     find_opts+=("${template_dir}") |     find_opts+=("${template_dir}") | ||||||
|     find_opts+=('-mindepth' '0') |     find_opts+=('-mindepth' '0') | ||||||
|     find_opts+=('-type' 'f') |     find_opts+=('-type' 'f') | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ declare -a fd_opts | |||||||
| declare -r blue='\033[0;34m' | declare -r blue='\033[0;34m' | ||||||
| declare -r nocolor='\033[0;0m' | declare -r nocolor='\033[0;0m' | ||||||
|  |  | ||||||
| [[ ! -x '/usr/bin/fd' ]] && echo 'fd is not present, cancelling' >&2 && exit 1 | [[ -z "$(which fd)" ]] && echo 'fd is not present, cancelling' >&2 && exit 1 | ||||||
|  |  | ||||||
| while true; do | while true; do | ||||||
|     case "${1}" in |     case "${1}" in | ||||||
| @@ -85,7 +85,7 @@ for filename in "${files[@]}"; do | |||||||
|     fi |     fi | ||||||
| done | done | ||||||
|  |  | ||||||
| printf '%s' "Would you like to delete these files? " | printf '%s' "Would you like to delete these files? [y/n] " | ||||||
| read -r -n 1 ans | read -r -n 1 ans | ||||||
|  |  | ||||||
| if [[ "${ans:-n}" =~ (Y|y) ]]; then | if [[ "${ans:-n}" =~ (Y|y) ]]; then | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user