I try to write an alias to check the git status for all packages under the same workspace. It is showed below:
alias ws-git-status="for d in *; do (cd $d && pwd && git status);done"
When I run the alais under my workspace, it reports error:
4702 ◯ pwd
/Users/adam/workplace
4c327596e4c7 ॐ ~/workplace:
4703 ◯ ws-git-status
/usr/share/zsh/5.2/functions
fatal: Not a git repository (or any of the parent directories): .git
But if I use single quote in the alias definition:
alias ws-git-status='for d in *; do (cd $d && pwd && git status);done'
It works pretty well. I search the diff between double and single quotes Difference between single and double quotes in Bash
It seems the double quote will take the value of $
but single quote will treat it like a character, which can not explain my case. Could anyone help me with some explanation or useful links? I am confused about this matter and unable to figure it out.