Skip to content

Commit

Permalink
An empty filename or directory is not allowed.
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaManSec committed Jan 11, 2024
1 parent b09bee2 commit d803989
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Snake.nocomments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Snake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d803989

Please sign in to comment.