commit 7b4a1cb1b450317d4d608a44fcb1f626652edcb0
parent 0525b0acc8f6f68f2d8e33fd014bfbe96cd93100
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 9 Jan 2023 12:02:15 +0100
Make the dump_netcdf_data.sh script POSIX compliant
Diffstat:
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/src/dump_netcdf_data.sh b/src/dump_netcdf_data.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh -e
# Copyright (C) 2018 |Meso|Star> (contact@meso-star.com)
#
@@ -14,26 +14,24 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
-set -e
-set -o pipefail
if [ $# -lt 2 ]; then
echo "Usage: $0 VAR-NAME MIE-NETCDF "
exit 0
fi
-if [ ! -f $2 ]; then
+if [ ! -f "$2" ]; then
echo "\"$2\" is not a valid file."
exit 0
fi
-name=$(basename $2)
+name=${2##*/}
name=${name%.*}
-ncdump -v $1 $2 \
+ncdump -v "$1" "$2" \
| sed -n "/^ *$1 *=/,\$p" \
| sed "s/^ *$1 *= *//g" \
| sed 's/[;} ]//g' \
| sed 's/,/\n/g' \
- | sed '/^ *$/d' > ${name}_${1}
+ | sed '/^ *$/d' > "${name}_${1}"