aboutsummaryrefslogtreecommitdiff
path: root/sh/shrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-12-19 13:32:44 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-12-19 13:32:44 +1300
commit0902a617fedd726f84092d3d06ca25bcca9124a9 (patch)
treec47a144decdd9467d518d90804f1b326d9dbb2d7 /sh/shrc.d
parentRemove lhn() (diff)
downloaddotfiles-0902a617fedd726f84092d3d06ca25bcca9124a9.tar.gz
dotfiles-0902a617fedd726f84092d3d06ca25bcca9124a9.zip
Only add -u to diff() call if more than two args
Diffstat (limited to 'sh/shrc.d')
-rw-r--r--sh/shrc.d/diff.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/sh/shrc.d/diff.sh b/sh/shrc.d/diff.sh
index 2c752c8d..179ced94 100644
--- a/sh/shrc.d/diff.sh
+++ b/sh/shrc.d/diff.sh
@@ -1,4 +1,16 @@
# Use a unified format for diff(1) by default
diff() {
- command diff -u "$@"
+ if (
+ for arg ; do
+ case $arg in
+ -*) shift ;;
+ --) shift ; break ;;
+ *) break ;;
+ esac
+ done
+ [ "$#" -gt 1 ]
+ ) ; then
+ set -- -u "$@"
+ fi
+ command diff "$@"
}