Debian Codegraph @

hash-example.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # hash-example.sh: Colorizing text.
3 # Author: Mariusz Gniazdowski <mariusz.gn-at-gmail.com>
4
5 . Hash.libscip-shell source . . `Hash.lib`. # Load the library of functions.
6
7 hash_set colors red "\033[0;31m"
8 hash_set colors blue "\033[0;34m"
9 hash_set colors light_blue "\033[1;34m"
10 hash_set colors light_red "\033[1;31m"
11 hash_set colors cyan "\033[0;36m"
12 hash_set colors light_green "\033[1;32m"
13 hash_set colors light_gray "\033[0;37m"
14 hash_set colors green "\033[0;32m"
15 hash_set colors yellow "\033[1;33m"
16 hash_set colors light_purple "\033[1;35m"
17 hash_set colors purple "\033[0;35m"
18 hash_set colors reset_color "\033[0;00m"
19
20
21 # $1 - keyname
22 # $2 - value
23 try_colorsscip-shell shell abs-guide 10-4 try_colors().() {
24 echoscip-shell system . . echo. -en "$2"
25 echoscip-shell system . . echo. "This line is $1."
26 }
27 hash_foreach colors try_colors
28 hash_echo colors reset_color -en
29
30 echoscip-shell system . . echo. -e '\nLet us overwrite some colors with yellow.\n'
31 # It's hard to read yellow text on some terminals.
32 hash_dup colors yellow red light_green blue green light_gray cyan
33 hash_foreach colors try_colors
34 hash_echo colors reset_color -en
35
36 echoscip-shell system . . echo. -e '\nLet us delete them and try colors once more . . .\n'
37
38 for i in red light_green blue green light_gray cyan; do
39 hash_unset colors $i
40 done
41 hash_foreach colors try_colors
42 hash_echo colors reset_color -en
43
44 hash_set other txt "Other examples . . ."
45 hash_echo other txt
46 hash_get_into other txt text
47 echoscip-shell system . . echo. $text
48
49 hash_set other my_fun try_colors
50 hash_call other my_fun purple "`hash_echo colors purple`"
51 hash_echo colors reset_color -en
52
53 echoscip-shell system . . echo.; echoscip-shell system . . echo. "Back to normal?"; echoscip-shell system . . echo.
54
55 exit $?
56
57 # On some terminals, the "light" colors print in bold,
58 # and end up looking darker than the normal ones.
59 # Why is this?
60