I am trying to configure a packet, but it regularly displays a message:
line 480: continue: it matters only for “for”, “while” or “until”

Swears at this line:
if[-z $var];then continue;fi

Script completely.

Tell me, how should the string look like?

1 Answers 1

break and continue are used only inside loops to control them.If you want to interrupt script execution when $var is not empty, then as an option

if![-z $var];then return 1;fi
  • And the shellcheck suggested using return instead of continue.And the script stopped getting errors.Is this solution correct? – Nutty Nightingale Oct 14 '18 at 15:46
  • [[nihi1ist]], what should happen if $var is not empty? Should the function not be executed further or should the entire script be completed? – Modern1 Oct 14 '18 at 15:54
  • [[Hanharr]], I don’t know, I generally understand it with a scientific method.The script must configure the sources for subsequent build. – Nutty Nightingale Oct 14 '18 at 16:16
  • [[nihi1ist]], well, if by typing, then suppose that

    if![-z $var];then return 1;fi

    It should work.As I understand it, if the $var variable is empty, then we continue to perform the function(program ???).Accordingly, we rewrite it so that if it is not empty, then we end the function.
    – Modern1 Oct 14 '18 at 16:56
  • [[Hanharr]], can you see the script itself? If there is an opportunity and desire of course.I think it will be so clearer? – Nutty Nightingale Oct 14 '18 at 17:06
  • [[nihi1ist]], I looked.And I didn’t have to admit, except for the construction of ideas described above.In general, it’s very strange that the author of this script used a construction with continue outside the loop in two places.And what package does script? – Modern1 Oct 14 '18 at 17:38
  • [[Hanharr]], an ancient bomi player.I’m still unable to build this package for Debian Testing. – Nutty Nightingale Oct 14 '18 at 18:14
  • [[nihi1ist]], fixing continue to return also didn't help? – Modern1 Oct 14 '18 at 18:21
  • [[Hanharr]], it helped.But I wonder how the correct option is. – Nutty Nightingale Oct 14 '18 at 19:06
  • [[nihi1ist]], you can ask the branch on the github.But, I suspect that they will advise the same thing.Either somehow they will fundamentally rewrite this fragment. – Modern1 Oct 14 '18 at 19:29
  • [[nihi1ist]], to know the correct version, you need to know what you actually need to do - exit, return with an error, stop execution.And you need to see a little more code.

    return works with functions, that is, if this is part of a function?
    – Gifted Grebe Oct 14 '18 at 22:46
  • [[saboteur_kiev]], yes, there is a function.I wonder if the function will spin in a loop, then can we continue or not use it?

    check_feature_one() {
        local var=$(get_feature_name)
        local pkg=$(get_option_field $f_pkg)
        local value=$(eval echo \ $$var)
        if[-z $var];then continue;fi
            if check_pkg"$pkg";then
                eval $var="enable"
                eval $var="disable"
        add_define HAVE_ $var 1
        add_define HAVE_ $var 0
    – Modern1 Oct 14 '18 at 22:51
  • [[Hanharr]],
    It is impossible.

    The bash parser in this case will not be able to find the loop, since it will check only the text of the function.
    – Gifted Grebe Oct 14 '18 at 23:51