Return “continue” from function called from loop

I’m currently refactoring a script which has slowly grown beyond control. I’m trying to spin off repetition into functions. However, I have a repeated test being called from a loop, and want it to return continue.

Shellcheck says

SC2104: In functions, use `return` instead of `continue`.

And the shellcheck wiki says don’t do it. But is there a way?

Below is an example:

#!/bin/sh

AFunction () {
    if [[ "${RED}" -lt 3 ]]; then
        echo "cont"
        continue
    else
        echo "nope"
    fi
}

for i in 1 2 3 4 5
do
    RED=${i}
    AFunction
    echo ${i}
done

This is the output:

cont
1
cont
2
nope
3
nope
4
nope
5

But I would expect

cont
cont
nope
3
nope
4
nope
5

Go to Source
Author: Stripy42

Fix Syntax error: unexpected end of file in a “for loop”

So I tried to fix this problem by myself for a couple of hours but I couldn’t
here’s the code block that has a problem I changed it, rewritten, I even tried to “do” only echo after each line but it doesn’t seem to work. It is a code to decrypt CSV files of a game for some event thing. In case u want, here’s full code https://pastebin.com/Gv3Fvyxy

for path in $(find assets -name "*.csv")

    do 

    f=$(echo "$path" | rev | cut -d"/" -f1 | rev)

        (

            dd if=$path bs=1 count=9 status=none

            dd if=/dev/zero bs=1 count=4 status=none

            dd if=$path bs=1 skip=9 status=none

        ) | lzma -dc -f > "decrypted/"$f

    done

Go to Source
Author: Dev