gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master ce66265 2/3: astscript-radial-profile: more po


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master ce66265 2/3: astscript-radial-profile: more portable making of temporary dir
Date: Thu, 25 Feb 2021 17:48:35 -0500 (EST)

branch: master
commit ce66265e4f83faf8299f12e24ad53e3df8b0c7ef
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    astscript-radial-profile: more portable making of temporary dir
    
    Until now the temporary directory was built with the 'mkdir -p'
    command. But the '-p' option is not portable on non-GNU operating systems.
    
    With this commit, this has been corrected by explicitly checking for the
    existance of the directory, and only running 'mkdir' when it doesn't exist.
---
 bin/script/radial-profile.in | 6 +++---
 doc/gnuastro.texi            | 2 ++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in
index 4eb9aa5..8bad552 100644
--- a/bin/script/radial-profile.in
+++ b/bin/script/radial-profile.in
@@ -370,13 +370,13 @@ bname_prefix=$(basename $inputs | sed 's/\.fits/ /' | awk 
'{print $1}')
 defaultname=$(pwd)/"$bname_prefix"_rprofile_$mode"_$xcenter"_"$ycenter"
 if [ x$output = x ]; then output="$defaultname.fits"; fi
 
-# Construct the temporal directory. If the user does not specify any
+# Construct the temporary directory. If the user does not specify any
 # directory, then a default one with the base name of the input image will
 # be constructed.  If the user set the directory, then make it. This
 # directory will be deleted at the end of the script if the user does not
 # want to keep it (with the `--keeptmp' option).
-if [ z$tmpdir = z        ]; then tmpdir=$defaultname; fi
-mkdir -p $tmpdir
+if [ x$tmpdir = x ]; then tmpdir=$defaultname; fi
+if [ -d $tmpdir ]; then junk=1; else mkdir $tmpdir; fi
 
 
 
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index de3e345..55da9d3 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -20448,6 +20448,7 @@ The output radial profile is a table (FITS or 
plain-text) containing the radial
 To measure the radial profile, this script needs to generate temporary files.
 All these temporary files will be created within the directory given to the 
@option{--tmpdir} option.
 When @option{--tmpdir} is not called, a temporary directory (with a name based 
on the inputs) will be created in the running directory.
+If the directory doesn't exist at run-time, this script will create it.
 After the output is created, this script will delete the directory by default, 
unless you call the @option{--keeptmp} option.
 
 With the default options, the script will generate a circular radial profile 
using the mean value and centered at the center of the image.
@@ -20551,6 +20552,7 @@ Several intermediate files are necessary to obtain the 
radial profile.
 All of these temporal files are saved into a temporal directory.
 With this option, you can directly specify this directory.
 By default (when this option isn't called), it will be built in the running 
directory and given an input-based name.
+If the directory doesn't exist at run-time, this script will create it.
 Once the radial profile has been obtained, this directory is removed.
 You can disable the deletion of the temporary directory with the 
@option{--keeptmp} option.
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]