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.

echo Element $i: ${arrayZ[$i]} is: ${#arrayZ[$i]} long.<br />

done<br />

echo<br />

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

# Which yields:<br />

# - - Test Two - -<br />

# Element 0: zero is: 4 long. # Our marker element<br />

# Element 1: ’Hello ${Me}’ is: 13 long. # Our "$(_pls ’...’ )"<br />

# Element 2: Hello ${You} is: 12 long. # Quotes are missing<br />

# Element 3: \’Pass: \’ is: 10 long. # ${pw} expanded to nothing<br />

# Now make an assignment with that result.<br />

declare -a array2=( ${arrayZ[@]} )<br />

# And print what happened.<br />

echo "- - Test Three - -"<br />

for (( i=0 ; i Expansion required, strip the quotes.<br />

# $( ... ) -> Replace with the result of..., strip this.<br />

# _pls ’ ... ’ -> called with literal arguments, strip the quotes.<br />

# The result returned includes hard quotes; BUT the above processing<br />

#+ has already been done, so they become part of the value assigned.<br />

#<br />

# Similarly, during further usage of the string variable, the ${Me}<br />

#+ is part of the contents (result) and survives any operations<br />

# (Until explicitly told to evaluate the string).<br />

# Hint: See what happens when the hard quotes ($’\x27’) are replaced<br />

#+ with soft quotes ($’\x22’) in the above procedures.<br />

# Interesting also is to remove the ad<strong>di</strong>tion of any quoting.<br />

# _Protect_Literal_String_Test<br />

# # # Remove the above "# " to <strong>di</strong>sable this code. # # #<br />

667

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

Saved successfully!

Ooh no, something went wrong!