diff --git a/README.md b/README.md index 80d97fa79f05a0b3e917a2af4dc480ccd73e7d81..c7f0c4c1ee4a5bd3be8ac4202a264dca49bdd7e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ + #### DESCRIPTION -Little bash Functions contains the following functions: +Little bash Functions contains the 9 following functions: show_time_fun test_tab_in_file_fun test_space_in_file_fun @@ -12,12 +13,33 @@ var_existence_check_fun file_exten_verif_name_recov_fun +#### LICENCE + +This package of scripts can be redistributed and/or modified under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. +Distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +See the GNU General Public License for more details at https://www.gnu.org/licenses. + + +#### CREDITS + +Gael A. Millot, Hub-C3BI, Institut Pasteur, USR 3756 IP CNRS, Paris, France + + #### HOW TO USE IT Download the desired Tagged version, never the current master. -Source the little_bash_functions.sh to have the functions available in the working environment. -Example: source /pasteur/homes/gmillot/Git_versions_to_use/little_bash_functions.sh +To directly source a version in the environment: +source <(curl -s https://gitlab.pasteur.fr/gmillot/little_bash_functions/raw/v1.0.0/little_bash_functions.sh) + +To directly save the little_bash_functions.sh file: +wget https://gitlab.pasteur.fr/gmillot/little_bash_functions/raw/v1.0.0/little_bash_functions.sh + +To save all the files: +wget https://gitlab.pasteur.fr/gmillot/little_bash_functions/-/archive/v1.0.0/little_bash_functions-v1.0.0.zip + +To source the local little_bash_functions.sh to have the functions available in the working environment: +source /pasteur/homes/gmillot/Git_versions_to_use/little_bash_functions-v1.0.0/little_bash_functions.sh Description of the functions is at the beginning of the function body. To obtain it, read the little_bash_functions.sh @@ -29,11 +51,16 @@ little_bash_functions.sh file that has to be sourced #### WEB LOCATION -Check for updated versions (more recent release tags) at https://gitlab.pasteur.fr/gmillot/little_bash_functions +Check for updated versions (more recent release tags) at https://gitlab.pasteur.fr/gmillot/little_bash_functions/tags #### WHAT'S NEW IN +## v1.1.0 + +single_path_with_regex_fun function deals now with url + + ## v1.0.0 -Creation +Everything diff --git a/little_bash_functions.sh b/little_bash_functions.sh index 8c162f4d04787d5e437895937bcd6292cbebf945..d12a4c4eb4b8ba68d8e40e5b10c987924f31fdba 100644 --- a/little_bash_functions.sh +++ b/little_bash_functions.sh @@ -1,4 +1,3 @@ - #!/bin/bash # shebang ################################################################ @@ -393,7 +392,7 @@ function test_column_nb_perline_in_file_fun () { fi } -function single_path_with_regex_fun { +function single_path_with_regex_fun { # comes from little_bash_functions-v1.0.0/little_bash_functions-v1.0.0.sh # DESCRIPTION # check that $1 path exists and is single # BEWARE @@ -405,7 +404,8 @@ function single_path_with_regex_fun { # 0: single path detected is valid # 1: error: $1 not provided # 2: error: $2 provided or more than one path detected - # 3: single path detected does not exist + # 3: single url detected does not exist + # 4: single path detected does not exist # EXAMPLES # single_path_with_regex_fun /cygdrive/c/Users/Gael/Desktop/config_tars_lodscore_gael_2017121[[:digit:]].conf # single_path_with_regex_fun /pasteur/homes/gmillot/dyslexia/code_gael/config_tars_lodscore_gael_2017121[[:digit:]].conf @@ -430,10 +430,16 @@ function single_path_with_regex_fun { return 2 else shopt -s extglob # -s unable global extention, ie the recognition of special global pattern in path, like [[:digit:]] - if [[ ! ( -d ${ARG1_ARR[0]} || -f ${ARG1_ARR[0]} ) ]] ; then + if [[ $(echo ${ARG1_ARR[0]} | grep -cE '^http' ) == 1 ]] ; then # -cE to specify extended and -c to return the number of match (here 0 or one only) + if [[ $(wget ${ARG1_ARR[0]} >/dev/null 2>&1 ; echo $?) != 0 ]] ; then # check the valid url. wget $url >/dev/null 2>&1 prevent any action and print. echo $? print the result of the last command (0 = success, other number = failure) + echo -e "\n### ERROR ### SPECIFIED URL IN single_path_with_regex_fun DOES NOT EXISTS: ${ARG1_ARR[0]}\n"; + shopt -u extglob # -u disable global extention, ie the recognition of special global pattern in path, like [[:digit:]] + return 3 + fi + elif [[ ! ( -d ${ARG1_ARR[0]} || -f ${ARG1_ARR[0]} ) ]] ; then echo -e "\n### ERROR ### SPECIFIED PATH IN single_path_with_regex_fun DOES NOT EXISTS: ${ARG1_ARR[0]}\n"; shopt -u extglob # -u disable global extention, ie the recognition of special global pattern in path, like [[:digit:]] - return 3 + return 4 else shopt -u extglob # -u disable global extention, ie the recognition of special global pattern in path, like [[:digit:]] return 0