diff options
| author | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2022-03-17 01:56:08 +0100 |
|---|---|---|
| committer | Mohammad Akhlaghi <mohammad@akhlaghi.org> | 2022-03-17 02:46:37 +0100 |
| commit | 9947331d7f0c23840db41d72c37bde3f8d575ab1 (patch) | |
| tree | 2f9ada4e77dec3bdb2b068e1996bee23a814d3b7 | |
| parent | e41da9f765999b65f684dc411c38378978838a72 (diff) | |
| download | gnuastro-9947331d7f0c.tar.gz | |
Installed scripts: not calling bash, several stylistic improvements
Until now, the 'astscript-fits-view' installed script had a shebang of
'/bin/bash', but this is not portable (not all systems have Bash!). All
other scripts had a standard '/bin/sh' shebang.
Also, to check equality in some parts of that script we were using '=='
instead of '=' to check for equality. But this doesn't follow stylistic
conventions of all our other installed scripts!
Also, when needing to check a variable against more than one string, the
scripts would use '[ $abc = x ] || [ $abc = y ]'. This is against good
shell scripting conventions because it involves two invocations of '[' (or
the 'test' program). However, if we simply use '-o' between the checks
(like '[ $abc = x -o $abc = y ]'), then we only call 'test' once and thus
speed up the script.
Finally, in some places, we were quoting static strings like '[ "$mode" =
"wcs"]'. This is also against good stylistc conventions in shell scripting:
static strings don't need quotation, so adding quotations over them will
confuse any reader.
With this commit, all the issues above have been addressed and these issues
have been uniformalized in the installed scripts. We should later define
these as coding conventions for installed scripts.
The points above were all raised [1] by Alexey Dokuchaev (who is kindly
packaging Gnuastro in FreeBSD). The point on the redundancy of "x-escaping"
(or using things like '[ x"$hdu" = x ]'), was not implemented because I see
it used in the './configure' script and have bad memories of not using it
(now that I checked, they may have been due to not quoting the shell
variable!).
While inspecting the codes, I noticed that when adding multiple input file
arguments to the scripts (during the 'while' script where we parse the
command-line arguments and options), when multiple arguments were given, we
were mistakenly reversing their order and adding an extra space to the
input argument name (with 'inputs="$1 $inputs"'). So the relevant line in
all the scripts was modified to put 'inputs="$1"' when 'inputs' is empty,
and 'inputs="$inputs $1"' when 'inputs' already has a value (more than one
argument was given). This fixes the order, and also doesn't add an extra
space when a single argument is given.
[1] https://lists.gnu.org/archive/html/bug-gnuastro/2022-03/msg00000.html
| -rw-r--r-- | bin/script/ds9-region.in | 19 | ||||
| -rw-r--r-- | bin/script/fits-view.desktop.in | 2 | ||||
| -rwxr-xr-x | bin/script/fits-view.in | 29 | ||||
| -rw-r--r-- | bin/script/psf-scale-factor.in | 22 | ||||
| -rw-r--r-- | bin/script/psf-select-stars.in | 21 | ||||
| -rw-r--r-- | bin/script/psf-stamp.in | 30 | ||||
| -rw-r--r-- | bin/script/psf-subtract.in | 19 | ||||
| -rw-r--r-- | bin/script/psf-unite.in | 10 | ||||
| -rw-r--r-- | bin/script/radial-profile.in | 25 | ||||
| -rw-r--r-- | bin/script/sort-by-night.in | 2 | ||||
| -rw-r--r-- | doc/announce-acknowledge.txt | 1 | ||||
| -rwxr-xr-x | tests/script/psf-stamp.sh | 2 |
12 files changed, 103 insertions, 79 deletions
diff --git a/bin/script/ds9-region.in b/bin/script/ds9-region.in index d3514b5..ac39442 100644 --- a/bin/script/ds9-region.in +++ b/bin/script/ds9-region.in @@ -133,7 +133,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -178,6 +178,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these ('-l*') will account for both the case where we # have an equal sign and where we don't. +inputs="" while [ $# -gt 0 ] do # Initialize 'tcol': @@ -230,7 +231,7 @@ do # Not an option (not starting with a '-'): assumed to be input FITS # file name. - *) input="$1 $input"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac # If a column was given, add it to possibly existing previous columns @@ -247,7 +248,7 @@ done # =================== # Make sure only two columns are given, then set the columns. -if [ x$col = x ]; then +if [ x"$col" = x ]; then echo "$scriptname: no columns specified, you can use '--column' (or '-c')" exit 1 else @@ -258,8 +259,10 @@ else fi fi -# Make sure the value to '--mode' is either 'wcs' or 'img'. -if [ $mode = "wcs" ] || [ $mode = "img" ]; then +# Make sure the value to '--mode' is either 'wcs' or 'img'. Note: '-o' +# means "or" and is preferred to '[ ] || [ ]' because only a single +# invocation of 'test' is done. Run 'man test' for more. +if [ "$mode" = wcs -o $mode = "img" ]; then junk=1 else echo "$scriptname: value to '--mode' ('-m') should be 'wcs' or 'img'" @@ -291,13 +294,13 @@ fi # Initalize the radius value if not given. If we are in WCS mode, select a # 3 arcsecond radius and if we are in image mode, select a 5 pixel radius. if [ x"$radius" = x ]; then - if [ $mode = "wcs" ]; then radius=1 + if [ "$mode" = wcs ]; then radius=1 else radius=3 fi fi # Set the units of the radius. -if [ x$mode = x"wcs" ]; then unit="\""; else unit=""; fi +if [ x"$mode" = xwcs ]; then unit="\""; else unit=""; fi @@ -314,7 +317,7 @@ if [ x"$namecol" != x ]; then printf "# Region name (or label) column: $namecol\n" >> $out fi printf "global color=%s width=%d\n" $color $width >> $out -if [ $mode = "wcs" ]; then printf "fk5\n" >> $out +if [ "$mode" = wcs ]; then printf "fk5\n" >> $out else printf "image\n" >> $out; fi diff --git a/bin/script/fits-view.desktop.in b/bin/script/fits-view.desktop.in index d702fbf..36a087b 100644 --- a/bin/script/fits-view.desktop.in +++ b/bin/script/fits-view.desktop.in @@ -31,6 +31,8 @@ # # Current maintainer: # Mohammad Akhlaghi <mohammad@akhlaghi.org> +# Contributing authors: +# Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com> # Copyright (C) 2020-2022 Free Software Foundation, Inc. # # This '.desktop' file is part of Gnuastro. Gnuastro is free software: you diff --git a/bin/script/fits-view.in b/bin/script/fits-view.in index 41de702..b7bc0e4 100755 --- a/bin/script/fits-view.in +++ b/bin/script/fits-view.in @@ -1,4 +1,4 @@ -#! /bin/bash +#!/bin/sh # View the contents of FITS files using DS9 (if there is an image in any of # the HDUs) or TopCat (when there is a table). This script can be called @@ -136,7 +136,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -227,7 +227,7 @@ do # Not an option (not starting with a '-'): assumed to be input FITS # file name. - *) inputs="$inputs $1"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac # In case '--ds9extra' was given, add it to any previous values. The @@ -258,8 +258,10 @@ if [ x"$ds9center" != x ]; then echo "$scriptname: no coordinate mode provided! $modeerrorinfo" exit 1 - # Make sure the value to '--mode' is either 'wcs' or 'img'. - elif [ $ds9mode = "wcs" ] || [ $ds9mode = "img" ]; then + # Make sure the value to '--mode' is either 'wcs' or 'img'. Note: '-o' + # means "or" and is preferred to '[ ] || [ ]' because only a single + # invocation of 'test' is done. Run 'man test' for more. + elif [ "$ds9mode" = wcs -o "$ds9mode" = img ]; then junk=1 else cat <<EOF @@ -302,7 +304,10 @@ ds9geoopt="-geometry $ds9geometry" # # zscale --> mode zscale # minmax --> mode minmax -if [ x"$ds9scale" = x ] || [ "$ds9scale" = "zscale" ]; then +# +# Note: '-o' means "or" and is preferred to '[ ] || [ ]' because only a +# single invocation of 'test' is done. Run 'man test' for more. +if [ x"$ds9scale" = x -o "$ds9scale" = "zscale" ]; then ds9scale="mode zscale" elif [ "$ds9scale" = "minmax" ]; then ds9scale="mode minmax" @@ -344,7 +349,7 @@ fi # To allow generic usage, if no input file is given (the `if' below is # true), then just open an empty ds9. -if [ "x$inputs" == "x" ]; then +if [ x"$inputs" = x ]; then $ds9exec $ds9geoopt else # Select the first input. @@ -359,13 +364,13 @@ else # If the first input existed and was a FITS file, then `check' will be # 0 ('astfits' was successful). - if [ "$check" == "0" ]; then + if [ "$check" = 0 ]; then # Input is image or table. type=$(astfits $input1 --hasimagehdu) # If the file was a image, then `check` will be 1. - if [ "$type" == "1" ]; then + if [ "$type" = 1 ]; then # If a HDU is given, add it to all the input file names (within # square brackets for DS9). @@ -380,14 +385,14 @@ else n0=$(astfits $input1 -h0 | awk '$1=="NAXIS"{print $3}') # Find the number of dimensions. - if [ "$n0" == "0" ]; then + if [ "$n0" = 0 ]; then ndim=$(astfits $input1 -h1 | awk '$1=="NAXIS"{print $3}') else ndim=$n0 fi; # Open DS9 based on the number of dimension. - if [ "$ndim" = "2" ]; then + if [ "$ndim" = 2 ]; then # 2D multi-extension file: use the "Cube" window to # flip/slide through the extensions. @@ -436,7 +441,7 @@ else # 'astfits' couldn't open the file. else - if [ -f $input1 ]; then + if [ -f "$input1" ]; then echo "'$input1' isn't a FITS file." else echo "'$input1' doesn't exist." diff --git a/bin/script/psf-scale-factor.in b/bin/script/psf-scale-factor.in index c898163..fc730e6 100644 --- a/bin/script/psf-scale-factor.in +++ b/bin/script/psf-scale-factor.in @@ -143,7 +143,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -188,6 +188,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these (`-l*') will account for both the case where we # have an equal sign and where we don't. +inputs="" while [ $# -gt 0 ] do case "$1" in @@ -248,7 +249,7 @@ do # Not an option (not starting with a `-'): assumed to be input FITS # file name. - *) inputs="$1 $inputs"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac done @@ -266,7 +267,7 @@ if [ x"$inputs" = x ]; then $scriptname: no input FITS image files. Run with '--help' for more information on how to run EOF exit 1 -elif [ ! -f $inputs ]; then +elif [ ! -f "$inputs" ]; then echo "$scriptname: $inputs: No such file or directory" exit 1 fi @@ -317,8 +318,11 @@ if [ x"$mode" = x ]; then $scriptname: no coordinate mode provided. You can use '--mode' (or '-O'), acceptable values are 'img' (for pixel coordinate) or 'wcs' (for celestial coordinates) EOF exit 1 -# Make sure the value to '--mode' is either 'wcs' or 'img'. -elif [ $mode = "wcs" ] || [ $mode = "img" ]; then + +# Make sure the value to '--mode' is either 'wcs' or 'img'. Note: '-o' +# means "or" and is preferred to '[ ] || [ ]' because only a single +# invocation of 'test' is done. Run 'man test' for more. +elif [ "$mode" = wcs -o "$mode" = img ]; then junk=1 else cat <<EOF @@ -365,14 +369,14 @@ objectid="$xcoord"_"$ycoord" # specify a output name, then a default value containing the center and # mode will be generated. bname_prefix=$(basename $inputs | sed 's/\.fits/ /' | awk '{print $1}') -if [ x$tmpdir = x ]; then \ +if [ x"$tmpdir" = x ]; then \ tmpdir=$(pwd)/"$bname_prefix"_psfmodelscalefactor fi -if [ -d $tmpdir ]; then +if [ -d "$tmpdir" ]; then junk=1 else - mkdir -p $tmpdir + mkdir -p "$tmpdir" fi @@ -386,7 +390,7 @@ fi # (RA/DEC), then transform them to IMG (pixel). Here, this is done by using # the WCS information from the original input image. If the original # coordinates were done in IMG, then just use them. -if [ $mode = wcs ]; then +if [ "$mode" = wcs ]; then xycenter=$(echo "$xcoord,$ycoord" \ | asttable --column='arith $1 $2 wcs-to-img' \ --wcsfile=$inputs --wcshdu=$hdu $quiet) diff --git a/bin/script/psf-select-stars.in b/bin/script/psf-select-stars.in index 35bfab1..04aa32e 100644 --- a/bin/script/psf-select-stars.in +++ b/bin/script/psf-select-stars.in @@ -16,7 +16,7 @@ # Raul Infante-Sainz <infantesainz@gmail.com> # Mohammad Akhlaghi <mohammad@akhlaghi.org> # Carlos Morales-Socorro <cmorsoc@gmail.com> -# Copyright (C) 2020-2021, Free Software Foundation, Inc. +# Copyright (C) 2020-2022 Free Software Foundation, Inc. # # Gnuastro is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -156,7 +156,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -203,8 +203,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these ('-l*') will account for both the case where we # have an equal sign and where we don't. - - +inputs="" while [ $# -gt 0 ] do case "$1" in @@ -277,7 +276,7 @@ do # Not an option (not starting with a `-'): assumed to be input FITS # file name. - *) inputs="$1 $input"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac done @@ -293,7 +292,7 @@ if [ x"$inputs" = x ]; then echo " $scriptname: no input image file specified." echo "Run with '--help' for more information on how to run." exit 1 -elif [ ! -f $inputs ]; then +elif [ ! -f "$inputs" ]; then echo "$scriptname: $inputs: No such file or directory." exit 1 fi @@ -402,18 +401,18 @@ parallax_error=$(echo "$parallaxanderrorcolumn" \ # specify an output name, then a default value containing the field, min, # and max magnitudes will will be generated. bname_prefix=$(basename $inputs | sed 's/\.fits/ /' | awk '{print $1}') -if [ x$tmpdir = x ]; then \ +if [ x"$tmpdir" = x ]; then \ tmpdir=$(pwd)/"$bname_prefix"_psfcreateselectstar_"$field"_"$brightmag"_"$faintmag" fi -if [ -d $tmpdir ]; then +if [ -d "$tmpdir" ]; then junk=1 else - mkdir -p $tmpdir + mkdir -p "$tmpdir" fi # Default output catalog file -if [ x$output = x ]; then +if [ x"$output" = x ]; then output="$bname_prefix"_psfcreateselectstar_"$field"_"$brightmag"_"$faintmag".fits fi @@ -474,7 +473,7 @@ if [ x"$catalog" != x ]; then else # Make a file for output of 'asttable'. - if [ -f $catalog_main ]; then + if [ -f "$catalog_main" ]; then echo "External Catalog already exists " else # Select stars with magnitude between brighter to fainter. diff --git a/bin/script/psf-stamp.in b/bin/script/psf-stamp.in index ef1ed7c..55002d1 100644 --- a/bin/script/psf-stamp.in +++ b/bin/script/psf-stamp.in @@ -13,9 +13,10 @@ # Original author: # Raul Infante-Sainz <infantesainz@gmail.com> # Contributing author(s): +# Mohammad Akhlaghi <mohammad@akhlaghi.org> # Carlos Morales-Socorro <cmorsoc@gmail.com> # Sepideh Eskandarlou <sepideh.eskandarlou@gmail.com> -# Copyright (C) 2021, Free Software Foundation, Inc. +# Copyright (C) 2021-2022 Free Software Foundation, Inc. # # Gnuastro is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -151,7 +152,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -196,6 +197,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these (`-l*') will account for both the case where we # have an equal sign and where we don't. +inputs="" while [ $# -gt 0 ] do case "$1" in @@ -260,7 +262,7 @@ do # Not an option (not starting with a `-'): assumed to be input FITS # file name. - *) inputs="$1 $inputs"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac done @@ -278,7 +280,7 @@ if [ x"$inputs" = x ]; then $scriptname: no input FITS image files. Run with '--help' for more information on how to run EOF exit 1 -elif [ ! -f $inputs ]; then +elif [ ! -f "$inputs" ]; then echo "$scriptname: $inputs: No such file or directory" exit 1 fi @@ -329,8 +331,10 @@ $scriptname: no coordinate mode provided. The '--mode' ('-O') takes one of the f EOF exit 1 -# Make sure the value to '--mode' is either 'wcs' or 'img'. -elif [ $mode = "wcs" ] || [ $mode = "img" ]; then +# Make sure the value to '--mode' is either 'wcs' or 'img'. Note: '-o' +# means "or" and is preferred to '[ ] || [ ]' because only a single +# invocation of 'test' is done. Run 'man test' for more. +elif [ "$mode" = wcs -o $mode = "img" ]; then junk=1 else cat <<EOF @@ -376,19 +380,19 @@ objectid="$xcoord"_"$ycoord" # output, it will be used for saving the output file. If the user does not # specify a output name, then a default value containing the center and # mode will be generated. -bname_prefix=$(basename $inputs | sed 's/\.fits/ /' | awk '{print $1}') -if [ x$tmpdir = x ]; then \ +bname_prefix=$(basename "$inputs" | sed 's/\.fits/ /' | awk '{print $1}') +if [ x"$tmpdir" = x ]; then \ tmpdir=$(pwd)/"$bname_prefix"_psfcreatemakestamp fi -if [ -d $tmpdir ]; then +if [ -d "$tmpdir" ]; then junk=1 else - mkdir -p $tmpdir + mkdir -p "$tmpdir" fi # Output -if [ x$output = x ]; then +if [ x"$output" = x ]; then output="$bname_prefix"_psfcreatemakestamp_$objectid.fits fi @@ -403,7 +407,7 @@ fi # (RA/DEC), then transform them to IMG (pixel). Here, this is done by using # the WCS information from the original input image. If the original # coordinates were done in IMG, then just use them. -if [ $mode = wcs ]; then +if [ "$mode" = wcs ]; then xycenter=$(echo "$xcoord,$ycoord" \ | asttable --column='arith $1 $2 wcs-to-img' \ --wcsfile=$inputs --wcshdu=$hdu $quiet) @@ -526,7 +530,7 @@ fi # # Only if the the user has specified a ring of normalization (--normradii). # Otherwise set the normalization value equal to 1.0 (no normalization). -if [ x"$normradiusmin" != x ] && [ x"$normradiusmax" != x ]; then +if [ x"$normradiusmin" != x -a x"$normradiusmax" != x ]; then # Generate the radial profile of the stamp, since it has been already # centered on the center of the object, it is not necessary to give the diff --git a/bin/script/psf-subtract.in b/bin/script/psf-subtract.in index 28bcab4..fb6189f 100644 --- a/bin/script/psf-subtract.in +++ b/bin/script/psf-subtract.in @@ -8,7 +8,7 @@ # Contributing author(s): # Mohammad Akhlaghi <mohammad@akhlaghi.org> # Zahra Sharbaf <zahra.sharbaf2@gmail.com> -# Copyright (C) 2021, Free Software Foundation, Inc. +# Copyright (C) 2021-2022 Free Software Foundation, Inc. # # Gnuastro is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -132,7 +132,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -177,6 +177,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these (`-l*') will account for both the case where we # have an equal sign and where we don't. +inputs="" while [ $# -gt 0 ] do case "$1" in @@ -225,7 +226,7 @@ do # Not an option (not starting with a `-'): assumed to be input FITS # file name. - *) inputs="$1 $inputs"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac done @@ -287,7 +288,7 @@ if [ x"$mode" = x ]; then echo "$scriptname: no coordinate mode provided! $modeerrorinfo" exit 1 # Make sure the value to '--mode' is either 'wcs' or 'img'. -elif [ $mode = "wcs" ] || [ $mode = "img" ]; then +elif [ "$mode" = wcs -o "$mode" = img ]; then junk=1 else cat <<EOF @@ -330,18 +331,18 @@ objectid="$xcoord"_"$ycoord" # specify a output name, then a default value containing the center and # mode will be generated. bname_prefix=$(basename $inputs | sed 's/\.fits/ /' | awk '{print $1}') -if [ x$tmpdir = x ]; then \ +if [ x"$tmpdir" = x ]; then \ tmpdir=$(pwd)/"$bname_prefix"_psfmodelscatteredlight fi -if [ -d $tmpdir ]; then +if [ -d "$tmpdir" ]; then junk=1 else - mkdir -p $tmpdir + mkdir -p "$tmpdir" fi # Output -if [ x$output = x ]; then +if [ x"$output" = x ]; then output="$bname_prefix"_psfmodelscatteredlight_$objectid.fits fi @@ -356,7 +357,7 @@ fi # (RA/DEC), then transform them to IMG (pixel). Here, this is done by using # the WCS information from the original input image. If the original # coordinates were done in IMG, then just use them. -if [ $mode = wcs ]; then +if [ "$mode" = wcs ]; then xycenter=$(echo "$xcoord,$ycoord" \ | asttable --column='arith $1 $2 wcs-to-img' \ --wcsfile=$inputs --wcshdu=$hdu $quiet) diff --git a/bin/script/psf-unite.in b/bin/script/psf-unite.in index ceabf4c..33a2eff 100644 --- a/bin/script/psf-unite.in +++ b/bin/script/psf-unite.in @@ -6,8 +6,9 @@ # Original author: # Raul Infante-Sainz <infantesainz@gmail.com> # Contributing author(s): +# Mohammad Akhlaghi <mohammad@akhlaghi.org> # Carlos Morales-Socorro <cmorsoc@gmail.com> -# Copyright (C) 2021, Free Software Foundation, Inc. +# Copyright (C) 2021-2022 Free Software Foundation, Inc. # # Gnuastro is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free @@ -135,7 +136,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -180,6 +181,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these (`-l*') will account for both the case where we # have an equal sign and where we don't. +inputs="" while [ $# -gt 0 ] do case "$1" in @@ -231,7 +233,7 @@ do # Not an option (not starting with a `-'): assumed to be input FITS # file name. - *) inputs="$1 $inputs"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac done @@ -260,7 +262,7 @@ if [ x"$inner" = x ]; then $scriptname: no inner FITS image provided. The inner part of the PSF (to unite with the outer part, which is the main argument) can be specified with the '--inner' (or '-i') option as a FITS image EOF exit 1 -elif [ ! -f $inner ]; then +elif [ ! -f "$inner" ]; then echo "$scriptname: $inner: No such file or directory." exit 1 fi diff --git a/bin/script/radial-profile.in b/bin/script/radial-profile.in index f78f122..2c5e56b 100644 --- a/bin/script/radial-profile.in +++ b/bin/script/radial-profile.in @@ -159,7 +159,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" @@ -204,6 +204,7 @@ EOF # if a value is appended to the short format it should crash. So in the # second test for these (`-l*') will account for both the case where we # have an equal sign and where we don't. +inputs="" while [ $# -gt 0 ] do case "$1" in @@ -276,7 +277,7 @@ do # Not an option (not starting with a `-'): assumed to be input FITS # file name. - *) inputs="$1 $inputs"; shift;; + *) if [ x"$inputs" = x ]; then inputs="$1"; else inputs="$inputs $1"; fi; shift;; esac # If a measurment was given, add it to possibly existing previous @@ -315,8 +316,10 @@ if [ x"$center" != x ]; then fi fi -# Make sure the value to '--mode' is either 'wcs' or 'img'. -if [ $mode = "wcs" ] || [ $mode = "img" ]; then +# Make sure the value to '--mode' is either 'wcs' or 'img'. Note: '-o' +# means "or" and is preferred to '[ ] || [ ]' because only a single +# invocation of 'test' is done. Run 'man test' for more. +if [ "$mode" = wcs -o $mode = "img" ]; then junk=1 else echo "$scriptname: value to '--mode' ('-m') should be 'wcs' or 'img'" @@ -360,7 +363,7 @@ else # The central position is in image mode; we should just separate each # coordinate. - if [ $mode = img ]; then + if [ "$mode" = img ]; then xcenter=$(echo "$center" | awk 'BEGIN{FS=","} {print $1}') ycenter=$(echo "$center" | awk 'BEGIN{FS=","} {print $2}') @@ -423,15 +426,15 @@ fi # generated. bname_prefix=$(basename $inputs | sed 's/\.fits/ /' | awk '{print $1}') defaultname=$(pwd)/"$bname_prefix"_radial_profile_$mode"_$xcenter"_"$ycenter" -if [ x$output = x ]; then output="$defaultname.fits"; fi +if [ x"$output" = x ]; then output="$defaultname.fits"; fi # 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 [ x$tmpdir = x ]; then tmpdir=$defaultname; fi -if [ -d $tmpdir ]; then junk=1; else mkdir $tmpdir; fi +if [ x"$tmpdir" = x ]; then tmpdir=$defaultname; fi +if [ -d "$tmpdir" ]; then junk=1; else mkdir $tmpdir; fi @@ -497,9 +500,9 @@ valuesbase=values.fits values=$tmpdir/$valuesbase valuesstdbase=valuesstd.fits valuesstd=$tmpdir/$valuesstdbase -if [ x$oversample = x ]; then +if [ x"$oversample" = x ]; then cd $tmpdir; ln -fs $cropbase $valuesbase; cd $curdir - if [ x"$instd" != x ] && [ -f "$instd" ]; then + if [ x"$instd" != x -a -f "$instd" ]; then cd $tmpdir; ln -fs $cropstdbase $valuesstdbase; cd $curdir fi else @@ -507,7 +510,7 @@ else ycenter=$(echo $ycenter | awk '{print '$oversample'*$1}') rmax=$(echo $rmax | awk '{print '$oversample'*$1}') astwarp $crop --scale=$oversample,$oversample -o$values - if [ x"$instd" != x ] && [ -f "$instd" ]; then + if [ x"$instd" != x -a -f "$instd" ]; then astwarp $cropstd --scale=$oversample,$oversample -o$valuesstd fi fi diff --git a/bin/script/sort-by-night.in b/bin/script/sort-by-night.in index 5cc7524..27837cf 100644 --- a/bin/script/sort-by-night.in +++ b/bin/script/sort-by-night.in @@ -137,7 +137,7 @@ EOF # Functions to check option values and complain if necessary. on_off_option_error() { - if [ "x$2" = x ]; then + if [ x"$2" = x ]; then echo "$scriptname: '$1' doesn't take any values" else echo "$scriptname: '$1' (or '$2') doesn't take any values" diff --git a/doc/announce-acknowledge.txt b/doc/announce-acknowledge.txt index 1f478ac..8826d4d 100644 --- a/doc/announce-acknowledge.txt +++ b/doc/announce-acknowledge.txt @@ -3,6 +3,7 @@ Alphabetically ordered list to acknowledge in the next release. Sergio Chueca Urzay Tamara Civera Lorenzo Andres Del Pino Molina +Alexey Dokuchaev Alessandro Ederoclite Sepideh Eskandarlou Juan Antonio Fernández Ontiveros diff --git a/tests/script/psf-stamp.sh b/tests/script/psf-stamp.sh index dac978a..d19d0d1 100755 --- a/tests/script/psf-stamp.sh +++ b/tests/script/psf-stamp.sh @@ -7,7 +7,7 @@ # Raul Infante-Sainz <infantesainz@gmail.com> # Contributing author(s): # Mohammad Akhlaghi <mohammad@akhlaghi.org> -# Copyright (C) 2015-2021, Free Software Foundation, Inc. +# Copyright (C) 2015-2022 Free Software Foundation, Inc. # # Copying and distribution of this file, with or without modification, # are permitted in any medium without royalty provided the copyright |
