learning shell display alert function
【Purpose】
Shell print function base on err info wrn ext output level
【Eevironment】
Ubuntu 16.04 bash env
【Procdeure】
Source code:
#!/bin/bash
DEST=/tmp
mkdir -p /tmp/debug
display_alert()
#--------------------------------------------------------------------------------------------------------------------------------
# Let's have unique way of displaying alerts
#--------------------------------------------------------------------------------------------------------------------------------
{
# log function parameters to install.log
#[[ -n $DEST ]] && echo "Displaying message: $@" >> $DEST/debug/output.log
local tmp=""
[[ -n $2 ]] && tmp="[\e[0;33m $2 \x1B[0m]"
case $3 in
err)
echo -e "[\e[0;31m error \x1B[0m] $1 $tmp"
;;
wrn)
echo -e "[\e[0;35m warn \x1B[0m] $1 $tmp"
;;
ext)
echo -e "[\e[0;32m o.k. \x1B[0m] \e[1;32m$1\x1B[0m $tmp"
;;
info)
echo -e "[\e[0;32m o.k. \x1B[0m] $1 $tmp"
;;
*)
echo -e "[\e[0;32m .... \x1B[0m] $1 $tmp"
;;
esac
}
display_alert "List of local repos" "local" "err"
display_alert "List of local repos" "local" "wrn"
display_alert "List of local repos" "local" "ext"
display_alert "List of local repos" "local" "info"
display_alert "List of local repos" "local" "other"
Test method:

learning shell display alert function的更多相关文章
- learning shell monitor prog function
[Purpose] Shell script monitor prog function [Eevironment] Ubuntu 16.04 bash env [ ...
- 不知道哪里alert undefined 用下面的语句是js报错.F12能提示报错的地方window.alert=function(aa){ if (typeof (aa)"undefined"){ throw "就是这";}};
不知道哪里alert undefined 用下面的语句是js报错.F12能提示报错的地方 var oldalert=window.alert; window.alert=function(aa){ i ...
- learning shell built-in variables (1)
Shell built-in variables [Purpose] Learning shell built-in variables, example $0,$1,$2,$3,$#, ...
- how to disabled alert function in javascript
how to disabled alert function in javascript alert 阻塞主线程 default alert; // ƒ alert() { [native code] ...
- learning shell args handing key=value example (2)
Shell args handing key=value example [Purpose] Learning how to handing ker=value args [Eevi ...
- learning shell script prompt to run with superuser privileges (4)
Shell script prompt to run with superuser privileges [Purpose] Check whether have root privil ...
- learning shell get script absolute path (3)
Shell get script absolute path [Purpose] Get shell script absolute path [Eevironment] ...
- learning shell check requires root privileges
[Purpose] Shell script check requires root privileges [Eevironment] Ubuntu 16.04 bas ...
- learning shell check host dependent pkg
[Purpose] Shell script check host dependent pkg [Eevironment] Ubuntu 16.04 bash env ...
随机推荐
- SqlServer中exists和in的区别
1.in 2.exists
- Springboot:没有src/main/resources目录(引入图片时(或静态资源时)发现没有该目录)
今天想在Springboot项目想引进静态资源时,发现自己的项目里没有教程里面的 src/main/resources这个目录,目录如下 我的项目目录结构是这样的,但是还不是很清楚下面的那个src目录 ...
- 力扣(LeetCode) 997. 找到小镇的法官
在一个小镇里,按从 1 到 N 标记了 N 个人.传言称,这些人中有一个是小镇上的秘密法官. 如果小镇的法官真的存在,那么: 小镇的法官不相信任何人. 每个人(除了小镇法官外)都信任小镇的法官. 只有 ...
- cmd中mvn命令,出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
在cmd里执行mvn命令,出错 查看mvn -v 发现mvn运行在jre上,更改高级设置.我的电脑-->属性-->高级系统设置-->环境变量 更改完之后,再次查看 mvn -v 搞定 ...
- MySQL学习(十五)
索引的概念 索引是数据的目录,能快速定位数据的位置.索引提高了查询速度,降低了增删改的速度.并非加的越多越好. 一般在查询频率高的列上加,而且在重复度低的列上加效果更好.如在性别列上不用加索引,但是身 ...
- 中文情况下,Eclipse的最好字体。
个人喜欢的是 Microsoft YaHei Mono 了. 下面的文章喜欢的是 YaHei Consolas Hybrid. 字体安装方法的话,拷贝到 widnows\fonts目录就行. http ...
- English trip V1 - 19.Where Am I? 我在哪里?Teacher:Patrick Key:Ask for and directions
In this lesson you will learn to ask for and give directions. 本节课你将学习到学会问路和指路. 课上内容(Lesson) 人类的几种感: ...
- 关于Handler中Message的创建问题
Message用来定义一个包含任意数据的消息对象,这个消息对象是可以被发送给Handler处理的. 我们最好通过Message.obtain()和Handler.obtatinMessage()来得到 ...
- numpy---one
import numpy as np #创建数组(给array函数传递Python序列对象) a = np.array([1,2,3,4,5]) b = np.array((1,2,3,4,5,6)) ...
- mysql之filesort原理
在执行计划中,可能经常看到有Extra列有filesort,这就是使用了文件排序,这当然是不好的,应该优化,但是,了解一下他排序的原理也许很有帮助,下面看一下filesort的过程: 1.根据表的索引 ...