1

i can't figure out, where is the problem

if [ $# -eq 1 ]; then
    if [ "$1"=="-h" ]; then
            help
    else
            echo "bad parameter, if you put only one parameter, you can choose only -h"
    fi

no matter what i give it as first parameter, script never gets to the else part and every time it is displaying help

1 Answer 1

4

Correct syntax:

if [ "$1" = "-h" ]
Sign up to request clarification or add additional context in comments.

2 Comments

see bash pitfalls for more help (many pitfalls regarding the test or [ command).
@sevdah: You should click the check mark by this answer to indicate that it solved your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.