سؤال

I'm trying to add an alias command to my gitconfig file and it reports "bad config file" on the line I've added. I suspect it's something to do with the sed command and some escaping issues, but I don't know exactly what it's supposed to be. Here's the command, with linebreaks added for legibility:

impact = !git ls-files -z
       | xargs -0n1 git blame -w -C
       | sed -r 's/^[^(]+\((.*) [0-9]{4}-.*/\1/'
       | sed -r 's/ +$//'
       | sort -f
       | uniq -c
       | sort -nr
هل كانت مفيدة؟

المحلول

I suspect it is more about the '\', which needs to be doubled.

I tried your alias with '\\' without any error message.

impact = !git ls-files -z
       | xargs -0n1 git blame -w -C
       | sed -r 's/^[^(]+\\((.*) [0-9]{4}-.*/\\1/'
       | sed -r 's/ +$//'
       | sort -f
       | uniq -c
       | sort -nr
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top