An empty filename or directory is not allowed.

This commit is contained in:
Joshua Rogers 2024-01-12 01:17:56 +07:00
parent b09bee2041
commit d803989131
2 changed files with 6 additions and 0 deletions

View File

@ -1063,6 +1063,7 @@ done
is_file() {
local filename
filename="$1"
[[ -z "$filename" ]] && return 1
[[ -v 'files["$filename"]' || ${#files["$filename"]} -gt 0 ]] && return 0
[[ -v 'not_files["$filename"]' || ${#not_files["$filename"]} -gt 0 ]] && return 1
${s} test -s "$filename" && ${s} test -r "$filename" && ${s} test -f "$filename" && files["$filename"]=1 && return 0
@ -1072,6 +1073,7 @@ return 1
is_dir() {
local dir_name
dir_name="$1"
[[ -z "$dir_name" ]] && return 1
[[ -v 'folders["$dir_name"]' || ${#folders["$dir_name"]} -gt 0 ]] && return 0
[[ -v 'not_folders["$dir_name"]' || ${#not_folders["$dir_name"]} -gt 0 ]] && return 1
${s} test -d "$dir_name" && ${s} test -r "$dir_name" && folders["$dir_name"]=1 && return 0

View File

@ -1785,6 +1785,8 @@ is_file() {
filename="$1"
[[ -z "$filename" ]] && return 1
[[ -v 'files["$filename"]' || ${#files["$filename"]} -gt 0 ]] && return 0
[[ -v 'not_files["$filename"]' || ${#not_files["$filename"]} -gt 0 ]] && return 1
@ -1800,6 +1802,8 @@ is_dir() {
dir_name="$1"
[[ -z "$dir_name" ]] && return 1
[[ -v 'folders["$dir_name"]' || ${#folders["$dir_name"]} -gt 0 ]] && return 0
[[ -v 'not_folders["$dir_name"]' || ${#not_folders["$dir_name"]} -gt 0 ]] && return 1