Skip to content

Commit 6233bb4

Browse files
committed
fix: oscap-ssh: instead of expr/let, use (( )) form
Handle options conversions up to 2nd last arg as last is input and is handled next. (( ..., 1 )) ensures return value is ok. arr[-1] is last element From shellcheck: In utils/oscap-ssh line 217: for i in $(seq 0 `expr $# - 1`); do ^-----------^ SC2046: Quote this to prevent word splitting. ^-----------^ SC2006: Use $(...) notation instead of legacy backticked `...`. ^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]. Did you mean: for i in $(seq 0 $(expr $# - 1)); do In utils/oscap-ssh line 218: let j=i+1 ^-------^ SC2219: Instead of 'let expr', prefer (( expr )) . In utils/oscap-ssh line 267: LOCAL_CONTENT_PATH="${oscap_args[`expr $# - 1`]}" ^-----------^ SC2006: Use $(...) notation instead of legacy backticked `...`. ^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]. Did you mean: LOCAL_CONTENT_PATH="${oscap_args[$(expr $# - 1)]}" In utils/oscap-ssh line 268: oscap_args[`expr $# - 1`]="$REMOTE_TEMP_DIR/input.xml" ^-----------^ SC2006: Use $(...) notation instead of legacy backticked `...`. ^--^ SC2003: expr is antiquated. Consider rewriting this using $((..)), ${} or [[ ]]. Did you mean: oscap_args[$(expr $# - 1)]="$REMOTE_TEMP_DIR/input.xml"
1 parent ff3cf70 commit 6233bb4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

utils/oscap-ssh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ TARGET_SYSCHAR=""
214214
OVAL_RESULTS=""
215215

216216
# We have to rewrite various paths to a remote temp dir
217-
for i in $(seq 0 `expr $# - 1`); do
218-
let j=i+1
217+
for (( i=0; i < $#-1; i++ )); do
218+
(( j=i+1, 1 ))
219219

220220
case "${oscap_args[i]}" in
221221
("--tailoring-file")
@@ -264,8 +264,8 @@ done
264264

265265
if [ "$1" != "--v" ] && [ "$1" != "--version" ] && [ "$1" != "-h" ] && [ "$1" != "--help" ]; then
266266
# Last argument should be the content path
267-
LOCAL_CONTENT_PATH="${oscap_args[`expr $# - 1`]}"
268-
oscap_args[`expr $# - 1`]="$REMOTE_TEMP_DIR/input.xml"
267+
LOCAL_CONTENT_PATH="${oscap_args[-1]}"
268+
oscap_args[-1]="$REMOTE_TEMP_DIR/input.xml"
269269
fi
270270

271271
[ "$LOCAL_CONTENT_PATH" == "" ] || [ -f "$LOCAL_CONTENT_PATH" ] || die "Expected the last argument to be an input file, '$LOCAL_CONTENT_PATH' isn't a valid file path or the file doesn't exist!"

0 commit comments

Comments
 (0)