How to fix input confuse in BASH?

Asked by At

I'm trying to put "help" command on my secript

read -p ">> " cmd
if ( $cmd == "help" )
then
       echo
       echo "help - this page"
else
       echo
       echo "error command"
fi

when i write help :

>> help
help: help [-dms] [pattern ...]
    Display information about builtin commands.

    Displays brief summaries of builtin commands.  If PATTERN is
    specified, gives detailed help on all commands matching PATTERN,
    otherwise the list of help topics is printed.

    Options:
      -d        output short description for each topic
      -m        display usage in pseudo-manpage format
      -s        output only a short usage synopsis for each topic matching
                PATTERN

    Arguments:
      PATTERN   Pattern specifying a help topic

    Exit Status:
    Returns success unless PATTERN is not found or an invalid option is given.

help - show this page

and i only want to see "help - show this page" not "help" of BASH

1 Answers

2
l'L'l On Best Solutions

The if statement should look like this (using double brackets):

if [[ $cmd = "help" ]]

This is the main issue with your script.