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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -