File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 4141 HAS_TTY=
4242fi
4343
44- if type -P colordiff > /dev/null; then
45- HAS_COLORDIFF=1
46- else
47- HAS_COLORDIFF=
48- fi
49-
5044function exit_usage() {
5145 local status=${1:- 0}
5246 [[ " $status " != " 0" ]] && exec >&2
@@ -156,6 +150,16 @@ function show_diff() {
156150 local hash action mtime owner file
157151 local -a ascii_files=( )
158152
153+ local diffcolortest=$( diff --color 2>&1 )
154+ if (( $? == 127 )) ; then
155+ error ' diff command not found'
156+ return 1
157+ elif [[ $diffcolortest != * ' unrecognized option' * ]]; then
158+ local diffcmd=( diff --color=auto )
159+ else
160+ local diffcmd=( diff )
161+ fi
162+
159163 while read hash acode action mtime perm owner file ; do
160164 printf " # %s %s %s %s %s %s\n" \
161165 " $acode " " $action " \
@@ -190,12 +194,7 @@ function show_diff() {
190194 (
191195 cd " $tempdir "
192196 find old -type f -printf " %P\0" |
193- xargs -0 -I{} diff --unidirectional-new-file -u old/{} new/{} |
194- if [[ -n $HAS_TTY && -n $HAS_COLORDIFF ]]; then
195- colordiff
196- else
197- cat
198- fi
197+ xargs -0 -I{} " ${diffcmd[@]} " --unidirectional-new-file -u old/{} new/{}
199198 )
200199 rm -rf " $tempdir "
201200 fi
You can’t perform that action at this time.
0 commit comments