Home Nested if failure - Pseudo code sample
Reply: 1

Nested if failure - Pseudo code sample

t988GF
1#
t988GF Published in 2017-12-07 21:20:36Z

For the past days I've been trying to understand why a script I have is failing, and execution all refers, in the error, to this part of the code (pseudo-code for this post):

if [ -z "${removed-unset}" ]; then
    ABC
    else
        if [ "$(date +%u)" == 4 ];  then
            if test `find "ABC" -cmin +2880` then
                if [ ! -f /tmp/ABC ]; then
                    CODE HERE
                        if [[ -s ABC ]]; then
                            CODE HERE
                                if [ -z "${ABC-unset}" ]; then
                                     CODE HERE
                                else
                                     CODE HERE
                                fi
                         else
                             rm ABC
                         fi
                 else
                     CODE HERE
                 fi
             else
                 CODE HERE
             fi
    else
        CODE HERE
    fi
fi

I was wondering if I could have some pointers as to what it is I'm doing wrong here. I apologize for the lack of actual code and the syntax.

that other guy
2#
that other guy Reply to 2017-12-07 22:23:48Z

ShellCheck points out that you're missing a semicolon:

if test `find "ABC" -cmin +2880` then
                                 ^-- SC1010: Use semicolon or linefeed before 'then' 
                                             (or quote to make it literal).

Just insert it as suggested:

if test `find "ABC" -cmin +2880`; then

This is required because then is only special at the start of a command.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.37721 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO