why this shell script output so strange -
#!/bin/bash echo "===========3333333=====" if [ $0 == "test" ] || $0 == "all" ];then echo "---" fi endless loop output:
===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== ===========3333333===== although know wrong missing square brackets if [ $0 == "test" ] || [ $0 == "all" ];then why output that???
consider line if [ $0 == "test" ] || $0 == "all" ]
this of form if cmd1 || cmd2, cmd1 [ $0 == "test ] , cmd2 $0 == "all" ]
that second command invoking script arguments ==, all, , ]. you've got recursion.
remember, [ not part of shell grammar. command strange feature of requiring last argument ].
Comments
Post a Comment