mirror of
https://github.com/libssh2/libssh2.git
synced 2025-08-01 11:26:53 +03:00
os400: fix shellcheck warnings in scripts
- use `$()` instead of backticks, and re-arrange double-quotes inside.
- add missing `|| exit 1` to `cd` calls. (could be dropped by using `set -eu`.)
- add `-n` to a few `if`s.
- shorten redirections by using `{} >` (as shellcheck recommended).
- silence warnings where variables were detected as unused (SC2034).
- a couple misc updates to silence warnings.
- switch to bash shebang for `-ot` feature.
- split two lines to unbreak syntax highlighting in my editor. (`$(expr \`, `$(dirname \`)
Also enable CI checks for OS/400 shell scripts.
Ref: d88b9bcdaf
Closes #1358
This commit is contained in:
56
os400/make-src.sh
Normal file → Executable file
56
os400/make-src.sh
Normal file → Executable file
@ -1,13 +1,13 @@
|
||||
#!/bin/sh
|
||||
#!/usr/bin/env bash
|
||||
# Copyright (C) The libssh2 project and its contributors.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
# libssh2 compilation script for the OS/400.
|
||||
#
|
||||
|
||||
SCRIPTDIR=`dirname "${0}"`
|
||||
SCRIPTDIR=$(dirname "${0}")
|
||||
. "${SCRIPTDIR}/initscript.sh"
|
||||
cd "${TOPDIR}/src"
|
||||
cd "${TOPDIR}/src" || exit 1
|
||||
|
||||
|
||||
# Function to extract external prototypes from header files.
|
||||
@ -48,10 +48,12 @@ fi
|
||||
|
||||
# Create and compile the identification source file.
|
||||
|
||||
echo '#pragma comment(user, "libssh2 version '"${LIBSSH2_VERSION}"'")' > os400.c
|
||||
echo '#pragma comment(user, __DATE__)' >> os400.c
|
||||
echo '#pragma comment(user, __TIME__)' >> os400.c
|
||||
echo '#pragma comment(copyright, "See COPYING file. OS/400 version by P. Monnerat")' >> os400.c
|
||||
{
|
||||
echo '#pragma comment(user, "libssh2 version '"${LIBSSH2_VERSION}"'")'
|
||||
echo '#pragma comment(user, __DATE__)'
|
||||
echo '#pragma comment(user, __TIME__)'
|
||||
echo '#pragma comment(copyright, "See COPYING file. OS/400 version by P. Monnerat")'
|
||||
} > os400.c
|
||||
make_module OS400 os400.c
|
||||
LINK= # No need to rebuild service program yet.
|
||||
MODULES=
|
||||
@ -80,28 +82,28 @@ fi
|
||||
|
||||
# Get source list.
|
||||
|
||||
cat Makefile.inc |
|
||||
sed -e ':begin' \
|
||||
-e '/\\$/{' \
|
||||
-e 's/\\$/ /' \
|
||||
-e 'N' \
|
||||
-e 'bbegin' \
|
||||
-e '}' \
|
||||
-e 's/\n//g' \
|
||||
-e 's/[[:space:]]*$//' \
|
||||
-e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
|
||||
-e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
|
||||
> tmpscript.sh
|
||||
sed -e ':begin' \
|
||||
-e '/\\$/{' \
|
||||
-e 's/\\$/ /' \
|
||||
-e 'N' \
|
||||
-e 'bbegin' \
|
||||
-e '}' \
|
||||
-e 's/\n//g' \
|
||||
-e 's/[[:space:]]*$//' \
|
||||
-e 's/^\([A-Za-z][A-Za-z0-9_]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1="\2"/' \
|
||||
-e 's/\$(\([A-Za-z][A-Za-z0-9_]*\))/${\1}/g' \
|
||||
< Makefile.inc > tmpscript.sh
|
||||
. ./tmpscript.sh
|
||||
|
||||
|
||||
# Compile the sources into modules.
|
||||
|
||||
INCLUDES="'`pwd`'"
|
||||
# shellcheck disable=SC2034
|
||||
INCLUDES="'$(pwd)'"
|
||||
|
||||
for SRC in "${TOPDIR}/os400/os400sys.c" "${TOPDIR}/os400/ccsid.c" \
|
||||
${CSOURCES} macros.c
|
||||
do MODULE=`db2_name "${SRC}"`
|
||||
do MODULE=$(db2_name "${SRC}")
|
||||
make_module "${MODULE}" "${SRC}"
|
||||
done
|
||||
|
||||
@ -112,7 +114,7 @@ if action_needed "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
if [ -n "${LINK}" ]
|
||||
then rm -rf "${LIBIFSNAME}/${STATBNDDIR}.BNDDIR"
|
||||
CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${STATBNDDIR})"
|
||||
CMD="${CMD} TEXT('libssh2 API static binding directory')"
|
||||
@ -145,10 +147,10 @@ fi
|
||||
|
||||
# Gather the list of symbols to export.
|
||||
|
||||
EXPORTS=`cat "${TOPDIR}"/include/*.h "${TOPDIR}/os400/macros.h" \
|
||||
EXPORTS=$(cat "${TOPDIR}"/include/*.h "${TOPDIR}/os400/macros.h" \
|
||||
"${TOPDIR}/os400/libssh2_ccsid.h" |
|
||||
extproto |
|
||||
sed -e 's/(.*//;s/[^A-Za-z0-9_]/ /g;s/ *$//;s/^.* //'`
|
||||
sed -e 's/(.*//;s/[^A-Za-z0-9_]/ /g;s/ *$//;s/^.* //')
|
||||
|
||||
# Create the service program exportation file in DB2 member if needed.
|
||||
|
||||
@ -158,7 +160,7 @@ if action_needed "${BSF}" Makefile.am
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
if [ -n "${LINK}" ]
|
||||
then echo " STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('LIBSSH2_${SONAME}')" \
|
||||
> "${BSF}"
|
||||
for EXPORT in ${EXPORTS}
|
||||
@ -175,7 +177,7 @@ if action_needed "${LIBIFSNAME}/${SRVPGM}.SRVPGM"
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
if [ -n "${LINK}" ]
|
||||
then CMD="CRTSRVPGM SRVPGM(${TARGETLIB}/${SRVPGM})"
|
||||
CMD="${CMD} SRCFILE(${TARGETLIB}/TOOLS) SRCMBR(BNDSRC)"
|
||||
CMD="${CMD} MODULE(${TARGETLIB}/OS400)"
|
||||
@ -199,7 +201,7 @@ if action_needed "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
||||
then LINK=YES
|
||||
fi
|
||||
|
||||
if [ "${LINK}" ]
|
||||
if [ -n "${LINK}" ]
|
||||
then rm -rf "${LIBIFSNAME}/${DYNBNDDIR}.BNDDIR"
|
||||
CMD="CRTBNDDIR BNDDIR(${TARGETLIB}/${DYNBNDDIR})"
|
||||
CMD="${CMD} TEXT('libssh2 API dynamic binding directory')"
|
||||
|
Reference in New Issue
Block a user