1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-07-02 14:02:26 +00:00

Merge pull request #88 from E5ten/master

log: replace use of literal escape code error with printf %b
This commit is contained in:
dylan 2020-01-22 18:53:02 +02:00 committed by GitHub
commit ccec6d39c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
kiss
View File

@ -15,17 +15,13 @@
log() { log() {
# Print a message prettily. # Print a message prettily.
# #
# This function uses the literal escape character (Ctrl+V+Escape) as
# a simple way of *safely* bypassing the escape sequence restrictions
# on 'printf %s'. Cheeky, I know.
#
# '\033[1;32m' Set text to color '2' and make it bold. # '\033[1;32m' Set text to color '2' and make it bold.
# '\033[m': Reset text formatting. # '\033[m': Reset text formatting.
# '${3:-->}': If the 3rd argument is missing, set prefix to '->'. # '${3:-->}': If the 3rd argument is missing, set prefix to '->'.
# '${2:+[1;3Xm}': If the 2nd argument exists, set the text style of '$1'. # '${2:+\033[1;3Xm}': If the 2nd argument exists, set text style of '$1'.
# '${2:+[m}': If the 2nd argument exists, reset text formatting. # '${2:+\033[m}': If the 2nd argument exists, reset text formatting.
printf '\033[1;33m%s \033[m%s\033[m %s\n' \ printf '\033[1;33m%s \033[m%b%s\033[m %s\n' \
"${3:-->}" "${2:+}$1${2:+}" "$2" "${3:-->}" "${2:+\033[1;36m}" "$1" "$2"
} }
die() { die() {