11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

hash_set colors blue "\033[0;34m"<br />

hash_set colors light_blue "\033[1;34m"<br />

hash_set colors light_red "\033[1;31m"<br />

hash_set colors cyan "\033[0;36m"<br />

hash_set colors light_green "\033[1;32m"<br />

hash_set colors light_gray "\033[0;37m"<br />

hash_set colors green "\033[0;32m"<br />

hash_set colors yellow "\033[1;33m"<br />

hash_set colors light_purple "\033[1;35m"<br />

hash_set colors purple "\033[0;35m"<br />

hash_set colors reset_color "\033[0;00m"<br />

# $1 - keyname<br />

# $2 - value<br />

try_colors() {<br />

echo -en "$2"<br />

echo "This line is $1."<br />

}<br />

hash_foreach colors try_colors<br />

hash_echo colors reset_color -en<br />

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

echo -e ’\nLet us overwrite some colors with yellow.\n’<br />

# It’s hard to read yellow text on some terminals.<br />

hash_dup colors yellow red light_green blue green light_gray cyan<br />

hash_foreach colors try_colors<br />

hash_echo colors reset_color -en<br />

echo -e ’\nLet us delete them and try colors once more . . .\n’<br />

for i in red light_green blue green light_gray cyan; do<br />

hash_unset colors $i<br />

done<br />

hash_foreach colors try_colors<br />

hash_echo colors reset_color -en<br />

hash_set other txt "Other examples . . ."<br />

hash_echo other txt<br />

hash_get_into other txt text<br />

echo $text<br />

hash_set other my_fun try_colors<br />

hash_call other my_fun purple "‘hash_echo colors purple‘"<br />

hash_echo colors reset_color -en<br />

echo; echo "Back to normal?"; echo<br />

exit $?<br />

# On some terminals, the "light" colors print in bold,<br />

# and end up looking darker than the normal ones.<br />

# Why is this?<br />

660

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!