Skip to content
Snippets Groups Projects
Commit b251ec8a authored by Gael  MILLOT's avatar Gael MILLOT
Browse files

v1.1.0 release

parent 791b4ac7
No related branches found
No related tags found
No related merge requests found
#### DESCRIPTION #### DESCRIPTION
Little bash Functions contains the following functions: Little bash Functions contains the 9 following functions:
show_time_fun show_time_fun
test_tab_in_file_fun test_tab_in_file_fun
test_space_in_file_fun test_space_in_file_fun
...@@ -12,12 +13,33 @@ var_existence_check_fun ...@@ -12,12 +13,33 @@ var_existence_check_fun
file_exten_verif_name_recov_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 #### HOW TO USE IT
Download the desired Tagged version, never the current master. Download the desired Tagged version, never the current master.
Source the little_bash_functions.sh to have the functions available in the working environment. To directly source a version in the environment:
Example: source /pasteur/homes/gmillot/Git_versions_to_use/little_bash_functions.sh 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 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 ...@@ -29,11 +51,16 @@ little_bash_functions.sh file that has to be sourced
#### WEB LOCATION #### 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 #### WHAT'S NEW IN
## v1.1.0
single_path_with_regex_fun function deals now with url
## v1.0.0 ## v1.0.0
Creation Everything
#!/bin/bash # shebang #!/bin/bash # shebang
################################################################ ################################################################
...@@ -393,7 +392,7 @@ function test_column_nb_perline_in_file_fun () { ...@@ -393,7 +392,7 @@ function test_column_nb_perline_in_file_fun () {
fi 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 # DESCRIPTION
# check that $1 path exists and is single # check that $1 path exists and is single
# BEWARE # BEWARE
...@@ -405,7 +404,8 @@ function single_path_with_regex_fun { ...@@ -405,7 +404,8 @@ function single_path_with_regex_fun {
# 0: single path detected is valid # 0: single path detected is valid
# 1: error: $1 not provided # 1: error: $1 not provided
# 2: error: $2 provided or more than one path detected # 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 # EXAMPLES
# single_path_with_regex_fun /cygdrive/c/Users/Gael/Desktop/config_tars_lodscore_gael_2017121[[:digit:]].conf # 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 # 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 { ...@@ -430,10 +430,16 @@ function single_path_with_regex_fun {
return 2 return 2
else else
shopt -s extglob # -s unable global extention, ie the recognition of special global pattern in path, like [[:digit:]] 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"; 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:]] shopt -u extglob # -u disable global extention, ie the recognition of special global pattern in path, like [[:digit:]]
return 3 return 4
else else
shopt -u extglob # -u disable global extention, ie the recognition of special global pattern in path, like [[:digit:]] shopt -u extglob # -u disable global extention, ie the recognition of special global pattern in path, like [[:digit:]]
return 0 return 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment