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.

#+ (in realtà passa gli argomenti alla funzione).<br />

self.get_nome # Bozo<br />

self.get_cognome # Bozeman<br />

self.get_eta # 28<br />

self.get_datanascita # 101272413<br />

self.show_datanascita # Sat Mar 17 20:13:33 MST 1973<br />

echo<br />

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

# typeset -f<br />

#+ per vedere le funzioni create (attenzione, visualizzazione su più pagine).<br />

exit 0<br />

Mariusz Gniazdowski ha fornito la seguente libreria hash da usare negli script.<br />

Esempio A-21. Libreria <strong>di</strong> funzioni hash<br />

# Hash:<br />

# Hash function library<br />

# Author: Mariusz Gniazdowski <br />

# Date: 2005-04-07<br />

# Functions making emulating hashes in <strong>Bash</strong> a little less painful.<br />

# Limitations:<br />

# * Only global variables are supported.<br />

# * Each hash instance generates one global variable per value.<br />

# * Variable names collisions are possible<br />

#+ if you define variable like __hash__hashname_key<br />

# * Keys must use chars that can be part of a <strong>Bash</strong> variable name<br />

#+ (no dashes, periods, etc.).<br />

# * The hash is created as a variable:<br />

# ... hashname_keyname<br />

# So if somone will create hashes like:<br />

# myhash_ + mykey = myhash__mykey<br />

# myhash + _mykey = myhash__mykey<br />

# Then there will be a collision.<br />

# (This should not pose a major problem.)<br />

Hash_config_varname_prefix=__hash__<br />

# Emulates: hash[key]=value<br />

#<br />

# Params:<br />

# 1 - hash<br />

# 2 - key<br />

# 3 - value<br />

656

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

Saved successfully!

Ooh no, something went wrong!