From 0039402f180fb193f9260b1e29ae8182a6f2b1c6 Mon Sep 17 00:00:00 2001 From: criscuol <alexis.criscuolo@pasteur.fr> Date: Wed, 24 Mar 2021 17:21:36 +0100 Subject: [PATCH] 2.01 --- README.md | 1 + contig_info.sh | 28 ++++++++++------------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 40c4344..5109a11 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Run _contig_info_ without option to read the following documentation: -r residue content statistics for each contig sequence instead of global statistics -t tab-delimited output + -h prints this help and exits ``` ## Examples diff --git a/contig_info.sh b/contig_info.sh index a853673..14a059d 100755 --- a/contig_info.sh +++ b/contig_info.sh @@ -32,7 +32,11 @@ # = VERSIONS = # # ============ # # # - VERSION=2.0.210315ac # + VERSION=2.01.210324ac # +# + modified temp file creation using TMPDIR variable # +# + adding option -h # +# # +# VERSION=2.0.210315ac # # + adding option -r # # + adding trap when interrupting script # # # @@ -70,7 +74,7 @@ # ================ # # # # # -if [ "$1" = "-?" ] || [ $# -lt 1 ] +if [ "$1" == "-h" ] || [ $# -lt 1 ] then echo -e "\n\033[1m contig_info v$VERSION $COPYRIGHT\033[0m"; cat <<EOF @@ -86,25 +90,14 @@ then -r residue content statistics for each contig sequence instead of global statistics -t tab-delimited output + -h prints this help and exits EOF - exit ; + [ "$1" == "-h" ] && exit 0 || exit 1 ; fi # # ############################################################################################################# -############################################################################################################# -# # -# ================ # -# = CONSTANTS = # -# ================ # -# # -# = temp directory ======================================================================================= # -# # - TEMP_DIR=${TMPDIR:-/tmp}; -# # -############################################################################################################# - ############################################################################################################# # # # ================ # @@ -112,11 +105,10 @@ fi # ================ # # # # = randomfile() ========================================================================================= # -# returns a random file name within /tmp/ # +# creates a random file within $TEMP_DIR and returns its name # # # randomfile() { - rdmf=$TEMP_DIR/$RANDOM; while [ -e $rdmf ]; do rdmf=$TEMP_DIR/$RANDOM ; done - echo $rdmf ; + echo $(mktemp -t -p ${TMPDIR:-/tmp}) ; } # # ############################################################################################################# -- GitLab