Function to test if argument is a non-empty file

This commit is contained in:
Jeremy Gardais 2020-03-12 09:30:00 +01:00
parent fef976bfec
commit 2baa5c3b74
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 13 additions and 1 deletions

View File

@ -12,6 +12,7 @@
debug=true
flag_clipboard=false
flag_inline=false
flag_file=false
null_service_url="https://null.101010.fr"
@ -31,6 +32,17 @@ debug_message() {
[ "${debug}" = "true" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG ${_message}"
}
# ]]]
# Function to check if the argument is a existent file [[[
is_file_exist() {
_file="${1}"
## If it's a non-empty file
if [ -s "${_file}" ]; then
flag_file=true
debug_message " Func is_file_exist: ${_file} seems to be a file and it's non-empty."
fi
}
# ]]]
# Function to get content type [[[
determine_content_type() {
_content="${1}"
@ -41,7 +53,7 @@ determine_content_type() {
## If it's a one line content
if [ "${_content_nb_line}" -eq "1" ]; then
### Verify if it's a path to a existent file
flag_file=""
is_file_exist "${_content}"
### Verify it it's a remote URL
flag_url=""
fi