From 2baa5c3b740169bcf89f470f95a837b00c4e2a1d Mon Sep 17 00:00:00 2001 From: Gardouille Date: Thu, 12 Mar 2020 09:30:00 +0100 Subject: [PATCH] Function to test if argument is a non-empty file --- send.to.0x0.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/send.to.0x0.sh b/send.to.0x0.sh index 665fb7c..a69b7be 100755 --- a/send.to.0x0.sh +++ b/send.to.0x0.sh @@ -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