diff highlighting in mod command confirmation

This commit is contained in:
Rob Pearce 2022-04-21 18:16:47 +10:00
parent 90af44e959
commit 35763c7b26
1 changed files with 12 additions and 22 deletions

34
t.sh
View File

@ -243,25 +243,6 @@ function dblog() {
[[ $DEBUG -eq 1 ]] && echo "$(date) ${FUNCNAME[1]}() $*" >/dev/stderr
}
if [[ 1 -eq 0 ]]; then
function action() {
echo -e "$BOLD$GREEN* $PLAIN$GREEN$*$PLAIN"
}
function warn() {
echo -e "$BOLD${YELLOW}WARNING: $PLAIN$YELLOW$*$PLAIN" >/dev/stderr
}
function error() {
echo -e "$BOLD${RED}ERROR: $PLAIN$RED$*$PLAIN" >/dev/stderr
}
function info() {
[[ $AUTOYES -eq 1 ]] && return
echo -e "$BOLD${CYAN}>> $PLAIN$CYAN$*$PLAIN"
}
fi
function confirm() {
local yn
if [[ $AUTOYES -eq 1 ]]; then
@ -713,7 +694,7 @@ function rename() { # rename uid new name goes here
function sedmod() { # sedmod uid 'sed command'
local uid sedscript newname sedrv rv file
local id
local id one two cur new
uid=$1
id=$(getid $uid)
@ -731,8 +712,17 @@ function sedmod() { # sedmod uid 'sed command'
return 1
fi
info "Current name: ${BOLD}${tasksum[$id]}"
info "New name: ${BOLD}${newname}"
cur="${tasksum[$id]}"
new="${newname}"
if [[ $sedscript =~ ^s\/.*\/.*\/.*$ ]]; then
one=$(echo "$sedscript" | awk -F/ '{ print $2 }')
two=$(echo "$sedscript" | awk -F/ '{ print $3 }')
cur=${cur/$one/$BOLD$STRIKE$RED$one^p^b}
new=${new/$two/$BOLD$GREEN$two^b}
fi
info "Current name: ${BOLD}${cur}"
info "New name: ${BOLD}${new}"
confirm "Is this correct"
if [[ $? -ne 0 ]]; then
inform "Aborted."