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的更多相关文章

  1. learning shell monitor prog function

    [Purpose]        Shell script monitor prog function   [Eevironment]        Ubuntu 16.04 bash env   [ ...

  2. 不知道哪里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 ...

  3. learning shell built-in variables (1)

    Shell built-in variables [Purpose]        Learning shell built-in variables, example $0,$1,$2,$3,$#, ...

  4. how to disabled alert function in javascript

    how to disabled alert function in javascript alert 阻塞主线程 default alert; // ƒ alert() { [native code] ...

  5. learning shell args handing key=value example (2)

    Shell args handing key=value example [Purpose]        Learning how to handing ker=value args   [Eevi ...

  6. learning shell script prompt to run with superuser privileges (4)

    Shell script prompt to run with superuser privileges [Purpose]        Check whether have root privil ...

  7. learning shell get script absolute path (3)

    Shell get script absolute path [Purpose]        Get shell script absolute path   [Eevironment]       ...

  8. learning shell check requires root privileges

    [Purpose]        Shell script check requires root privileges   [Eevironment]        Ubuntu 16.04 bas ...

  9. learning shell check host dependent pkg

    [Purpose]        Shell script check host dependent pkg   [Eevironment]        Ubuntu 16.04 bash env ...

随机推荐

  1. ES6的新API如Promise,Proxy,Array.form(),Object.assign()等,Babel不能转码, 使用babel-polyfill来解决

    Babel默认只转换新的JavaScript句法(syntax),而不转换新的API,比如Iterator.Generator.Set.Maps.Proxy.Reflect.Symbol.Promis ...

  2. Linux-Ubuntu16.0.4相关命令

    1.更新软件源 sudo apt-get update 2.shell命令 基本格式:命令  [-选项] [-命令参数] ls #查看当前文件夹下的文件 ls -l XXXX #查看XXXX文件夹下的 ...

  3. ROS中遇到的一些问题和解决(更新)

    检查 roscore 是否正常打开 [ERROR] Failed to contact master at [localhost:11311]. Retrying... [ERROR] [144653 ...

  4. NexT 个性化设置

    NexT 主题添加分类页面 新建页面 在本地使用终端 cd 到 blog 文件夹下,执行如下命令: $ cd Documents/blog $ hexo new page categories 设置页 ...

  5. gcc请不要优化

    gdb跟踪剖发现free_area_init中一段优化错了,如下:    memset(mem_map, 0, start_mem - (unsigned long) mem_map);    do ...

  6. Java -------- 首字母相关排序总结

    Java 字符串数组首字母排序 字符串数组按首字母排序:(区分大小写) String[] strings = new String[]{"ba","aa",&q ...

  7. 发布web站点数据库环境的问题

    今天在公司部署web站点的时候发现了一个比较低级的错误,公司映射的外网的IP我们内部人员是无法进行访问的,结果我把站点配置文件中的IP改成是外网的IP,站点一直无法访问到数据.后面发现问题是,当外网用 ...

  8. Vmware安装Kali

    下载软件 破解版的Vmware14 kali(我的是kali-linux-2018.2-amd64) 配置虚拟机 新建虚拟机,选择自定义 虚拟机硬件兼容性 选择虚拟机硬件兼容性为Workstation ...

  9. 以CapsNet为例谈深度学习源码阅读

    本文的参考的github工程链接:https://github.com/laubonghaudoi/CapsNet_guide_PyTorch 之前是看过一些深度学习的代码,但是没有养成良好的阅读规范 ...

  10. 6.4 操作契约 Operation Contracts

    4.操作契约 Operation Contracts  “用例描述”的补充  强调: 用例中重要的动作,其开始与结束是需要一些约束 4.5 操作契约的后置条件  定义Definition  后 ...