Bash code to print all folders:for f in ~/*;doif [ $f  == '/home/sk/.' -o $f  == '/home/sk/..' ]; then       true  else     echo $f  fidoneIt works on bash. When i ran the code on z shell, it threw error: = not foundThen I converted [ into [[, ] into ]] to avoid this error in z shell and ran it on z shell. It threw next error:condition expected: $fWith [[ and ]], bash also throws error as:syntax error in conditional expressionsyntax error near `-o'Is there a POSIX standard to do string comparison in shell, that works across shells?
String comparison in single brackets in zsh
bash;zsh;test
There are various issues here. First, == is not standard, the POSIX way is =. Same goes for the -o. This one will work on both bash and zsh:for f in ~/*;doif [ $f  = '/home/sk/.' ] || [ $f  = '/home/sk/..' ]; then       true  else     echo $f  fidoneNote that your if is unneeded, dotfiles are ignored by default in both bash and zsh. You can simply write:for f in ~/*; do echo $f; doneOr even printf %s\n ~/*