1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-31 00:03:08 +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:
Viktor Szakats
2024-04-08 13:49:23 +00:00
parent 6a2f5f2736
commit c6625707b9
7 changed files with 88 additions and 82 deletions

18
os400/make-rpg.sh Normal file → Executable file
View 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
#
# Installation of the ILE/RPG header files in the OS/400 library.
#
SCRIPTDIR=`dirname "${0}"`
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/initscript.sh"
cd "${TOPDIR}/os400/libssh2rpg"
cd "${TOPDIR}/os400/libssh2rpg" || exit 1
# Create the OS/400 source program file for the ILE/RPG header files.
@ -24,9 +24,9 @@ fi
# Map file names to DB2 name syntax.
for HFILE in *.rpgle *.rpgle.in
do NAME="`basename \"${HFILE}\" .in`"
VAR="`basename \"${NAME}\" .rpgle`"
VAL="`db2_name \"${NAME}\"`"
do NAME="$(basename "${HFILE}" .in)"
VAR="$(basename "${NAME}" .rpgle)"
VAL="$(db2_name "${NAME}")"
eval "VAR_${VAR}=\"${VAL}\""
echo "${VAR} s/${VAR}/${VAL}/g"
@ -64,7 +64,7 @@ fi
for HFILE in *.rpgle *.rpgle.in
do IFSCMD="cat \"${HFILE}\""
DB2CMD="change_include < \"${HFILE}\""
IFSFILE="`basename \"${HFILE}\" .in`"
IFSFILE="$(basename "${HFILE}" .in)"
case "${HFILE}" in
@ -79,7 +79,7 @@ do IFSCMD="cat \"${HFILE}\""
then eval "${IFSCMD}" > "${IFSDEST}"
fi
eval DB2MBR="\"\${VAR_`basename \"${IFSDEST}\" .rpgle`}\""
eval DB2MBR="\"\${VAR_$(basename "${IFSDEST}" .rpgle)}\""
DB2DEST="${SRCPF}/${DB2MBR}.MBR"
if action_needed "${DB2DEST}" "${HFILE}"
@ -87,7 +87,7 @@ do IFSCMD="cat \"${HFILE}\""
# Need to translate to target CCSID.
CMD="CPY OBJ('`pwd`/tmphdrfile') TOOBJ('${DB2DEST}')"
CMD="CPY OBJ('$(pwd)/tmphdrfile') TOOBJ('${DB2DEST}')"
CMD="${CMD} TOCCSID(${TGTCCSID}) DTAFMT(*TEXT) REPLACE(*YES)"
system "${CMD}"
fi