OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.5 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: lib/term-functions.in
  5. # Copyright (C) 2006 - 2007 The OpenSDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- SDE-COPYRIGHT-NOTE-END ---
  14. # COLOR_*
  15. # FIXME: is the tty capable?
  16. #
  17. # '\E[COLOR1;COLOR2m'
  18. #
  19. # Color Fg Bg
  20. # black 30 40
  21. # red 31 41
  22. # green 32 42
  23. # yellow 33 43
  24. # blue 34 44
  25. # magenta 35 45
  26. # cyan 36 46
  27. # white 37 47
  28. #
  29. COLOR_NORMAL='\033[0m'
  30. COLOR_INFO='\033[32;1m'
  31. COLOR_TITLE='\033[35m'
  32. COLOR_MESSAGE='\033[36m'
  33. COLOR_SUCESS='\033[32m'
  34. COLOR_WARNING='\033[33;1m'
  35. COLOR_FAILURE='\033[31m'
  36. # CLI fanciness
  37. #
  38. echo_msg() {
  39. echo -e "${COLOR_MESSAGE}$*${COLOR_NORMAL}" >&2
  40. }
  41. echo_info() {
  42. if [ ${verbose:-1} -ne 0 ]; then
  43. if [ $# -gt 0 ]; then
  44. echo -e "${COLOR_INFO}->${COLOR_NORMAL} $*" >&2
  45. else
  46. while read text; do
  47. echo -e "${COLOR_INFO}->${COLOR_NORMAL} $text"
  48. done >&2
  49. fi
  50. fi
  51. }
  52. echo_warning() {
  53. echo -e "${COLOR_WARNING}*>${COLOR_NORMAL} $*" >&2
  54. }
  55. echo_error() {
  56. echo -e "${COLOR_FAILURE}!> ERROR:${COLOR_NORMAL} $@" >&2
  57. }
  58. echo_abort() {
  59. local errno="$1"; shift
  60. echo_error "$@"
  61. exit $errno
  62. }