I am trying to make a history file manipulations scripts. When I try to, for instance implement an incognito mode by running unset HISTFILEIt doesn't work due to command running in new shell. When I try . ./scriptThe command works, but conditionals I use to process arguments passed to script cause syntax error. Is there any workaround for this?Solved: the issue was wrong conditionals usage and unadaptation of script for zsh.case $1 in    (set)        HISTFILE=$2        HISTFILESIZE=$3        ;;    (incognito)        unset HISTFILE        ;;    (removesizelimit)        HISTSIZE=-1        HISTFILESIZE=-1        ;;    (clear)        rm -f $HISTFILE        unset HISTFILE && exit        ;;    (backup)        tar -cf HISTFILE.tar $HISTFILE        ;;    ()        echo Usage:        echo  . ./history <option>        echo  . ./history set <HISTSIZE> <HISTFILESIZE>        echo        echo Manipulate history file        echo        echo Options:        echo -e  incognito\t\t\tdo not record history of commands in this session        echo -e  removesizelimit\t\tremove limitation of size of history file        echo -e  clear\t\t\t\tclear history of run commands        echo -e  backup\t\t\t\tclear create a backup of history file in archive        ;;    (*)        echo ERROR: Option unrecognized        echo        echo run . ./history for helpesac
Conditionals do not work in . ./script
shell;shell script
n.b. most of this answer made much more sense before the question's edit :)The mistake is a simple one:if [ $1 == proto ]; then    TESTVAR=if [ $1 == set ]; then    HISTFILE=$2    HISTFILESIZE=$3elif [ $1 == incognito ]; then# ....The second if here should be elif. bash is complaining because it can't find a matching fi.There are also two other things I'd like to mention about the script:This will run in a subshell and execute the output of the unset command, which is not what you want:$(unset HISTFILE)You should remove the $(...) operator from it.The #!/bin/bash implies that the script is executable stand-alone as an argument to the /bin/bash binary. That doesn't make sense for a script like this, so I would advise against it (and I would advise against setting the executable permission on it).One last thing. Argument parsing via nested if/else is a bit of a clunky way to do things. You can use a case statement:case $1 in    (proto) TESTVAR= ;;    (set)        HISTFILE=$2        HISTFILESIZE=$3        ;;    #...etc...    ()        # ... put your usage here...        ;;    (*)        echo >&2 ERROR: Option unrecognized        echo >&2        echo >&2 run . ./history.bash for help        ;;esacMaking the script work under zsh:Replace usage of == with =. The == operator is a non-standard alias to the = operator, and this is one of the cases in which it breaks.Rename HISTFILESIZE to SAVEHIST