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.

# Recursion limiter<br />

# limit_chk() <br />

limit_chk() {<br />

local -i _lc_lmt<br />

# Check in<strong>di</strong>rection limit.<br />

if [ ${in<strong>di</strong>rect} -eq 0 ] || [ $# -eq 0 ]<br />

then<br />

# The ’do-forever’ choice<br />

echo 1 # Any value will do.<br />

return 0 # OK to continue.<br />

else<br />

# Limiting is in effect.<br />

if [ ${in<strong>di</strong>rect} -lt ${1} ]<br />

then<br />

echo ${1} # Whatever.<br />

return 1 # Stop here.<br />

else<br />

_lc_lmt=${1}+1 # Bump the given limit.<br />

echo ${_lc_lmt} # Echo it.<br />

return 0 # OK to continue.<br />

fi<br />

fi<br />

}<br />

# For each name in uc_name:<br />

# Move name to chk_name.<br />

# Add addresses to uc_address.<br />

# Pend expand_input_address.<br />

# Repeat until nothing new found.<br />

# expand_input_name <br />

expand_input_name() {<br />

[ ${#uc_name[@]} -gt 0 ] || return 0<br />

local -a _ein_addr<br />

local -a _ein_new<br />

local -i _ucn_cnt<br />

local -i _ein_cnt<br />

local _ein_tst<br />

_ucn_cnt=${#uc_name[@]}<br />

if ! _ein_cnt=$(limit_chk ${1})<br />

then<br />

return 0<br />

fi<br />

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

for (( _ein = 0 ; _ein < _ucn_cnt ; _ein++ ))<br />

do<br />

if short_fwd ${uc_name[${_ein}]} _ein_new<br />

then<br />

for (( _ein_cnt = 0 ; _ein_cnt < ${#_ein_new[@]}; _ein_cnt++ ))<br />

do<br />

_ein_tst=${_ein_new[${_ein_cnt}]}<br />

if is_address ${_ein_tst}<br />

690

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

Saved successfully!

Ooh no, something went wrong!