gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master 39ab85b 1/2: astscript-sort-by-night: AWK comm


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 39ab85b 1/2: astscript-sort-by-night: AWK command not using -v
Date: Wed, 24 Apr 2019 07:20:47 -0400 (EDT)

branch: master
commit 39ab85bf365352da9d41a0ebb39d3f7e1c414c32
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    astscript-sort-by-night: AWK command not using -v
    
    Until now, this installed script's AWK command used the `-v' option to
    define a variable on the command-line. However, the `-v' option is not
    available on some AWK implementations.
    
    With this commit, the calls to AWK don't use this option so it can be more
    portable.
    
    Also, the `tests/during-dev.sh' script has been modified to make it easy to
    test the installed scripts.
    
    This bug was reported by David Valls-Gabaud.
---
 NEWS                         | 15 +++++++++++++++
 bin/fits/fits.c              | 16 ++++++++--------
 bin/script/sort-by-night.in  | 25 +++++++++++--------------
 doc/announce-acknowledge.txt |  2 +-
 tests/during-dev.sh          | 21 ++++++++++++++++-----
 5 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/NEWS b/NEWS
index 39557c3..6a99ad9 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,21 @@ GNU Astronomy Utilities NEWS                          -*- 
outline -*-
 Copyright (C) 2015-2019 Free Software Foundation, Inc.
 See the end of the file for license conditions.
 
+* Noteworthy changes in release X.X (library X.X.X) (XXXX-XX-XX) [stable]
+
+** New features
+
+** Removed features
+
+** Changed features
+
+** Bugs fixed
+  bug #56195: astscript-sort-by-night crashing because of AWK.
+
+
+
+
+
 * Noteworthy changes in release 0.9 (library 7.0.0) (2019-04-17) [stable]
 
 ** New features
diff --git a/bin/fits/fits.c b/bin/fits/fits.c
index 24e58ec..432bbbd 100644
--- a/bin/fits/fits.c
+++ b/bin/fits/fits.c
@@ -109,17 +109,17 @@ fits_print_extension_info(struct fitsparams *p)
   /* Allocate all the columns (in reverse order, since this is a simple
      linked list). */
   gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
-                          p->cp.minmapsize, "HDU_SIZE", "name", "Size of "
-                          "image or table number of rows and columns.");
+                          -1, "HDU_SIZE", "name", "Size of image or table "
+                          "number of rows and columns.");
   gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
-                          p->cp.minmapsize, "HDU_TYPE", "name", "Image "
-                          "data type or `table' format (ASCII or binary).");
+                          -1, "HDU_TYPE", "name", "Image data type or "
+                          "`table' format (ASCII or binary).");
   gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_STRING, 1, &numext, NULL, 1,
-                          p->cp.minmapsize, "EXTNAME", "name",
-                          "Extension name of this HDU (EXTNAME in FITS).");
+                          -1, "EXTNAME", "name", "Extension name of this "
+                          "HDU (EXTNAME in FITS).");
   gal_list_data_add_alloc(&cols, NULL, GAL_TYPE_UINT16, 1, &numext, NULL, 1,
-                          p->cp.minmapsize, "HDU_INDEX", "count", "Index "
-                          "(starting from zero) of each HDU (extension).");
+                          -1, "HDU_INDEX", "count", "Index (starting from "
+                          "zero) of each HDU (extension).");
 
 
   /* Keep pointers to the array of each column for easy writing. */
diff --git a/bin/script/sort-by-night.in b/bin/script/sort-by-night.in
index 34cfb36..31c4d26 100644
--- a/bin/script/sort-by-night.in
+++ b/bin/script/sort-by-night.in
@@ -240,16 +240,15 @@ fi
 # To do this, we'll convert the date into Unix epoch time (seconds
 # since 1970-01-01,00:00:00) and keep that with the filename.
 list=$(for f in $inputs; do
-           astfits $f --datetosec=$key --hdu=$hdu -q      \
-               | awk -vh=$hour                            \
-                     '{d=int($1/86400); print "'$f'", $1, \
-                       int($1)%86400<(h*3600) ? d-1 : d }'
+           astfits $f --datetosec=$key --hdu=$hdu -q \
+               | awk '{h='$hour'; d=int($1/86400);   \
+                       print "'$f'", $1,             \
+                       int($1)%86400<(h*3600) ? d-1 : d }';
        done)
 
 
 
 
-
 # To see the result of the step above, uncomment the next line. You
 # can use a similar line to inspect the steps for later variables also
 # (just changing the variable name). IMPORTANT NOTE: Just don't forget
@@ -273,18 +272,16 @@ unique=$(echo "$list" | awk '{print $3}' | sort | uniq | 
cat -n)
 counter=1
 echo "$unique" | while read l; do
 
-    # Find all input files (and their Unix epoch time) that corr
+    # Find all input files (and their Unix epoch time).
     daynum_to=$(echo $l | awk '{print $1}')
     daynum_from=$(echo $l | awk '{print $2}')
     in_this_day=$(echo "$list" \
-                      | awk -vf=$daynum_from -vt=$daynum_to \
-                            '$3==f {print $1, $2}' \
-                      | sort -nk2 \
-                      | cat -n \
-                      | awk -vd=$counter '{print $2,d,$1}')
-
-    # Make a link to each file (containing the day number and image
-    # number in that day).
+                       | awk '$3=='$daynum_from' {print $1, $2}' \
+                       | sort -nk2 \
+                       | cat -n \
+                       | awk '{print $2,'$counter',$1}')
+
+    # Now that we know this night's files, we can take the proper action.
     echo "$in_this_day" | while read L; do
 
         # Set the necessary numbers.
diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt
index 89f5bcb..97a8052 100644
--- a/doc/announce-acknowledge.txt
+++ b/doc/announce-acknowledge.txt
@@ -1,6 +1,6 @@
 Alphabetically ordered list to acknowledge in the next release.
 
-
+David Valls-Gabaud
 
 
 
diff --git a/tests/during-dev.sh b/tests/during-dev.sh
index 676f69b..61a4edb 100755
--- a/tests/during-dev.sh
+++ b/tests/during-dev.sh
@@ -105,8 +105,8 @@ if [ x"$builddir" = x ]; then echo "builddir is not set."; 
exit 1; fi
 
 
 # Make sure `utilname' doesn't start with `ast' (a common mistake).
-nameprefix="${utilname:0:3}"
-if [ x"$nameprefix" = x"ast" ]; then
+astprefix="${utilname:0:3}"
+if [ x"$astprefix" = x"ast" ]; then
     echo "'utilname' must not start with 'ast'."; exit 1;
 fi
 
@@ -122,7 +122,13 @@ fi
 
 
 # Set the utility's executable file name
-utility="$builddir/bin/$utilname/ast$utilname"
+longprefix="${utilname:0:6}"
+if [ x"$longprefix" = x"script" ]; then
+    execdir="script"
+else
+    execdir="$utilname"
+fi
+utility="$builddir/bin/$execdir/ast$utilname"
 
 
 # If the utility is already built, then remove the executable so it is
@@ -160,8 +166,13 @@ if make -j$numjobs -C "$builddir"; then
     else
         topconfdir="$srcdir"
     fi
-    cp "$srcdir/bin/gnuastro.conf"                                    \
-       "$topconfdir/bin/$utilname/ast$utilname.conf" .gnuastro/
+
+    # Copy the configuration file(s).
+    cfiles="$srcdir/bin/gnuastro.conf"
+    if [ x"$longprefix" != x"script" ]; then
+        cfiles="$cfiles $topconfdir/bin/$utilname/ast$utilname.conf"
+    fi
+    cp $cfiles .gnuastro/
 
     # Append `lastconfig' option to `gnuastro.conf', so the program doesn't
     # go into the system headers.



reply via email to

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