[packages/adapter: 456/631] - use $PAGER for screen paging (defaults to less -r) - added ~/.adapterrc support
glen
glen at pld-linux.org
Mon Sep 12 20:12:40 CEST 2016
commit 2d894d6b398ab10561f11a118c7c465e2e6edab1
Author: sparky <sparky at pld-linux.org>
Date: Tue Dec 1 10:04:53 2009 +0000
- use $PAGER for screen paging (defaults to less -r)
- added ~/.adapterrc support
Changed files:
adapter.sh -> 1.42
adapter.sh | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/adapter.sh b/adapter.sh
index cb698ab..a1ef26a 100644
--- a/adapter.sh
+++ b/adapter.sh
@@ -47,6 +47,18 @@ if [ ! -x /usr/bin/patch ]; then
exit 1
fi
+[ -n "$PAGER" ] || PAGER="/usr/bin/less -r"
+
+if [ -n "$CONFIG_DIR" ]; then
+ USER_CFG="$CONFIG_DIR/.adapterrc"
+elif [ -n "$HOME_ETC" ]; then
+ USER_CFG="$HOME_ETC/.adapterrc"
+else
+ USER_CFG=~/.adapterrc
+fi
+
+[ -f $USER_CFG ] && . $USER_CFG
+
t=$(getopt -o hsomdaV --long help,version,sort,sort-br,no-macros,skip-macros,skip-desc,skip-defattr -n "$PROGRAM" -- "$@") || exit $?
eval set -- "$t"
@@ -104,17 +116,6 @@ diffcol()
' "$@"
}
-showdiff()
-{
- l=$(cat $1 | wc -l)
- eval $(resize) # get terminal size
- if [ $l -gt $LINES ]; then
- diffcol $1 | less -r
- else
- diffcol $1
- fi
-}
-
diff2hunks()
{
# diff2hunks orignally by dig
@@ -233,7 +234,7 @@ adapterize() {
elif [ "$(diff --brief $SPECFILE $tmp)" ]; then
diff -u $SPECFILE $tmp > $tmp.diff
if [ -t 1 ]; then
- showdiff $tmp.diff
+ diffcol $tmp.diff | $PAGER
while : ; do
echo -n "Accept? (Yes, No, Confirm each chunk)? "
read ans
@@ -246,7 +247,7 @@ adapterize() {
[cC]) # confirm each chunk
diff2hunks $tmp.diff
for t in $(ls $tmp-*.diff); do
- showdiff $t
+ diffcol $t | $PAGER
echo -n "Accept? (Yes, [N]o, Quit)? "
read ans
case "$ans" in
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/adapter.git/commitdiff/6ca0126d4d0c8c79feb7db10b0a0fade0f3b8885
More information about the pld-cvs-commit
mailing list