Skip to content

Commit 36452cc

Browse files
committed
Fix shellcheck issues in caf wrapper scripts
1 parent 672b422 commit 36452cc

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

src/extensions/caf-foot

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmd=`basename $0`
1+
cmd=$(basename "$0")
22

33
usage()
44
{
@@ -24,7 +24,7 @@ usage()
2424
echo " 1. With an OpenCoarrays-Aware (OCA) compiler (GNU 5.1.0 or later),"
2525
echo " a. If any of the options listed above appear, any remaining arguments are ignored."
2626
echo " b. If present, <fortran-source-file> must"
27-
echo " * be a Fortran source file,"
27+
echo " * be a Fortran source file,"
2828
echo " * appear before all other arguments,"
2929
echo " * be the only Fortran source file in the argument list,"
3030
echo " * have a name of the form *.f90, *.F90, *.f, or *.F. "
@@ -87,28 +87,28 @@ elif [[ $1 == '-h' || $1 == '--help' ]]; then
8787
exit 1
8888
elif [ "$caf_compiler" = "true" ]; then
8989
# Nothing to do other than invoke the compiler with all the command-line arguments:
90-
$CAFC "$@" -L $caf_lib_dir $link_args
90+
$CAFC "$@" -L "$caf_lib_dir" $link_args
9191
else
9292
# Verify that a file with the .f90, .F90, .f, or .F extension is the first argument:
93-
src_extension=`echo "$1" | cut -f2 -d'.'`
93+
src_extension=$(echo "$1" | cut -f2 -d'.')
9494
if [[ $src_extension == 'f90' || $src_extension == 'F90' || $src_extension == 'f' || $src_extension == 'F' ]]; then
9595
# copy the source file into a new file for pre-processing (preprending "caf-" to the new file name):
96-
cp $1 caf-$1
96+
cp "$1" "caf-$1"
9797
# Edit the copied source to replace CAF syntax with calls to public procedures in opencoarrays.f90:
9898
if [ "$linux" = "true" ]; then
99-
sed -i'' 's/sync all/call sync_all/g' caf-$1
100-
sed -i'' 's/error stop/call error_stop/g' caf-$1
101-
sed -i'' 's/sync images/call sync_images/g' caf-$1
99+
sed -i'' 's/sync all/call sync_all/g' "caf-$1"
100+
sed -i'' 's/error stop/call error_stop/g' "caf-$1"
101+
sed -i'' 's/sync images/call sync_images/g' "caf-$1"
102102
else
103103
# This works on OS X and other POSIX-compliant operating systems:
104-
sed -i '' 's/sync all/call sync_all/g' caf-$1
105-
sed -i '' 's/error stop/call error_stop/g' caf-$1
106-
sed -i '' 's/sync images/call sync_images/g' caf-$1
104+
sed -i '' 's/sync all/call sync_all/g' "caf-$1"
105+
sed -i '' 's/error stop/call error_stop/g' "caf-$1"
106+
sed -i '' 's/sync images/call sync_images/g' "caf-$1"
107107
fi
108108
# Replace the file name in command-line argment 1 with the new name beofre invoking the compiler:
109-
set -- "caf-$1" "${@:2:max_arguments}"
109+
set -- "caf-$1" "${@:2:$max_arguments}"
110110
# Invoke the compiler along with all command-line arguments:
111-
$CAFC "$@" -L $caf_lib_dir -I $caf_mod_dir $link_args
111+
$CAFC "$@" -L "$caf_lib_dir" -I "$caf_mod_dir" $link_args
112112
else
113113
# Print usage information upon encountering an unknowon CAF source file extension
114114
usage | less

src/extensions/caf-head

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
# Coarray Fortran (CAF) Compiler Wrapper
44
#
55
# Invokes the chosen Fortran compiler with the received command-line
6-
# arguments.
6+
# arguments.
77
#
88
# Copyright (c) 2015-2016, Sourcery, Inc.
99
# All rights reserved.
10-
#
10+
#
1111
# Redistribution and use in source and binary forms, with or without
1212
# modification, are permitted provided that the following conditions are met:
1313
# * Redistributions of source code must retain the above copyright
@@ -18,7 +18,7 @@
1818
# * Neither the name of the Sourcery, Inc., nor the
1919
# names of its contributors may be used to endorse or promote products
2020
# derived from this software without specific prior written permission.
21-
#
21+
#
2222
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2323
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2424
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -28,5 +28,5 @@
2828
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2929
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3030
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3232
#

src/extensions/cafrun-foot

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
usage()
1+
Usage()
22
{
3-
cmd=`basename $0`
3+
cmd=$(basename "$0")
44
echo ""
55
echo " $cmd - Coarray Fortran executable launcher for OpenCoarrays"
66
echo ""
@@ -29,6 +29,7 @@ if [ $# == 0 ]; then
2929
usage
3030
elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
3131
echo ""
32+
# shellcheck disable=SC2154
3233
echo "OpenCoarrays Coarray Fortran Executable Launcher (caf version $caf_version)"
3334
echo "Copyright (C) 2015-2016 Sourcery, Inc."
3435
echo ""

src/extensions/cafrun-head

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 2015-2016, Sourcery, Inc.
66
# All rights reserved.
7-
#
7+
#
88
# Redistribution and use in source and binary forms, with or without
99
# modification, are permitted provided that the following conditions are met:
1010
# * Redistributions of source code must retain the above copyright
@@ -15,7 +15,7 @@
1515
# * Neither the name of the Sourcery, Inc., nor the
1616
# names of its contributors may be used to endorse or promote products
1717
# derived from this software without specific prior written permission.
18-
#
18+
#
1919
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2020
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2121
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -25,11 +25,11 @@
2525
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2626
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2727
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28-
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
28+
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
3030
# This script invokes the chosen Fortran compiler with the received command-line
3131
# arguments. Current assumptions:
3232
# 1. The only argument is either an informational flag or a CAF executable
33-
# file.
34-
# 2. The environment variable "FC" is used to determine the identity fo the Fortran compiler/linker.
35-
# 3. If "FC" is empty, a default value of "mpif90" is used.
33+
# file.
34+
# 2. The environment variable "FC" is used to determine the identity fo the Fortran compiler/linker.
35+
# 3. If "FC" is empty, a default value of "mpif90" is used.

0 commit comments

Comments
 (0)