I want to look at the output of
git status -s to determine whether there are any untracked files in the tree. I tried the following test, but the regex doesn't match. Why not?
$ git status -s ## master M updated-file ?? new-file $ [[ $(git status -s) =~ ^\?\? ]] || echo "no match" no match
I'd also like to be able to test for added/modified/deleted files in the same way. I'd normally just use something like
^\s*[AMD] for this purpose, but this doesn't work either. What gives?
??. The match is against the whole string, not each line in the string. You probably want to match against
$'\n'??. What not use
git status -s | grep -q '^??' || echo no match