From 0de0b3cd2bbcaac56b857bbced66ee41e3193973 Mon Sep 17 00:00:00 2001 From: colben Date: Tue, 12 Apr 2022 08:03:17 +0800 Subject: [PATCH] update --- templates/dynamic/ext/sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/templates/dynamic/ext/sh b/templates/dynamic/ext/sh index 59484fb..52b3fc0 100755 --- a/templates/dynamic/ext/sh +++ b/templates/dynamic/ext/sh @@ -3,8 +3,9 @@ cat <<-EOF #!/bin/bash #========================================= -# Author : Colben +# Company : Boyachain # Create : $(date +"%F %R") +# Author : Who the f**k r u! #========================================= set -euo pipefail @@ -14,14 +15,14 @@ trap Quit EXIT PID_FILE=/tmp/\$(basename \${0%.sh}).pid if [ -t 0 ]; then - function Print { echo -e "\033[32;1m\$(date +'[%F %T]') \$*\033[0m"; } - function Warn { echo -e "\033[33;1m\$(date +'[%F %T]') \$*\033[0m"; } - function Error { echo -e "\033[31;1m\$(date +'[%F %T]') \$*\033[0m"; exit 1; } + function Print { echo -e "\033[36;1m\$(date +'[%F %T]')\033[32;1m \$*\033[0m"; } + function Warn { echo -e "\033[36;1m\$(date +'[%F %T]')\033[33;1m \$*\033[0m"; } + function Error { echo -e "\033[36;1m\$(date +'[%F %T]')\033[31;1m \$*\033[0m"; exit 1; } else #exec &> \${0%.sh}.out - function Print { echo -e "\$(date +'[%F %T] INFO') \$*"; } - function Warn { echo -e "\$(date +'[%F %T] WARN') \$*"; } - function Error { echo -e "\$(date +'[%F %T] ERRRO') \$*"; exit 1; } + function Print { echo -e "\$(date +'[%F %T INFO]') \$*"; } + function Warn { echo -e "\$(date +'[%F %T WARN]') \$*"; } + function Error { echo -e "\$(date +'[%F %T ERROR]') \$*"; exit 1; } fi function Quit { @@ -33,17 +34,17 @@ function Quit { } function Func1 { - Print Func1 ... + Warn Func1 ... } function Func2 { - Print Func2 ... + Warn Func2 ... } function Main { [ -e "\$PID_FILE" ] && Error Pid file \$PID_FILE already exists, quit! echo \$\$ > \$PID_FILE - Print Main ... + Warn Main ... Func1 Func2 END=1