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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

#### Special IFS settings used for string parsing. ####<br />

# Whitespace == :Space:Tab:Line Feed:Carriage Return:<br />

WSP_IFS=$’\x20’$’\x09’$’\x0A’$’\x0D’<br />

# No Whitespace == Line Feed:Carriage Return<br />

NO_WSP=$’\x0A’$’\x0D’<br />

# Field separator for dotted decimal IP addresses<br />

ADR_IFS=${NO_WSP}’.’<br />

# Array to dotted string conversions<br />

DOT_IFS=’.’${WSP_IFS}<br />

# # # Pen<strong>di</strong>ng operations stack machine # # #<br />

# This set of functions described in func_stack.bash.<br />

# (See "Ad<strong>di</strong>tional documentation" above.)<br />

# # #<br />

# Global stack of pen<strong>di</strong>ng operations.<br />

declare -f -a _pen<strong>di</strong>ng_<br />

# Global sentinel for stack runners<br />

declare -i _p_ctrl_<br />

# Global holder for currently executing function<br />

declare -f _pend_current_<br />

# # # Debug version only - remove for regular use # # #<br />

#<br />

# The function stored in _pend_hook_ is called<br />

# imme<strong>di</strong>ately before each pen<strong>di</strong>ng function is<br />

# evaluated. Stack clean, _pend_current_ set.<br />

#<br />

# This thingy demonstrated in pend_hook.bash.<br />

declare -f _pend_hook_<br />

# # #<br />

# The do nothing function<br />

pend_dummy() { : ; }<br />

# Clear and initialize the function stack.<br />

pend_init() {<br />

unset _pen<strong>di</strong>ng_[@]<br />

pend_func pend_stop_mark<br />

_pend_hook_=’pend_dummy’ # Debug only.<br />

}<br />

# Discard the top function on the stack.<br />

pend_pop() {<br />

if [ ${#_pen<strong>di</strong>ng_[@]} -gt 0 ]<br />

then<br />

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

673

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

Saved successfully!

Ooh no, something went wrong!