Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

7
  • 1
    Maybe try capturing stderr also, Commented May 12, 2020 at 2:09
  • Hello. Can you give an example of the usage of stderr? Thank you very much. Commented May 12, 2020 at 2:13
  • 1
    here 2>&1 use that and see if it solve your issue. Commented May 12, 2020 at 2:17
  • Is this correct? GIT_DIFF=$(git diff RB_202005:/test.txt RB_202006:/test.txt 2>&1) Another question, how should I print the stderr? Commented May 12, 2020 at 4:28
  • 1
    If those two files match, git diff prints nothing, so the variable is set to the empty string and printing it prints nothing. Only if the two files differ, or there is some error in computing the diff, will the variable be set to something other than the empty string. Commented May 12, 2020 at 5:57