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.

Capitolo 9. Variabili riviste<br />

Utilizzate in modo appropriato, le variabili possono aumentare la potenza e la flessibilità degli script. Per<br />

questo è necessario conoscere tutte le loro sfumature e sottigliezze.<br />

9.1. Variabili interne<br />

Variabili builtin (incorporate)<br />

$BASH<br />

$BASH_ENV<br />

$BASH_SUBSHELL<br />

$BASH_VERSINFO[n]<br />

sono quelle variabili che determinano il comportamento dello script bash<br />

il percorso dell’eseguibile <strong>Bash</strong><br />

bash$ echo $BASH<br />

/bin/bash<br />

variabile d’ambiente che punta al file <strong>di</strong> avvio <strong>di</strong> <strong>Bash</strong>, che deve essere letto quando si invoca uno<br />

script<br />

variabile che in<strong>di</strong>ca il livello della subshell. Si tratta <strong>di</strong> una nuova variabile aggiunta in <strong>Bash</strong>,<br />

versione 3.<br />

Per il suo impiego ve<strong>di</strong> Esempio 20-1.<br />

un array <strong>di</strong> 6 elementi contenente informazioni sulla versione <strong>Bash</strong> installata. È simile a<br />

$BASH_VERSION, ve<strong>di</strong> oltre, ma più dettagliata.<br />

# Informazioni sulla versione <strong>Bash</strong>:<br />

for n in 0 1 2 3 4 5<br />

do<br />

echo "BASH_VERSINFO[$n] = ${BASH_VERSINFO[$n]}"<br />

done<br />

# BASH_VERSINFO[0] = 3 # Nr. della major version.<br />

# BASH_VERSINFO[1] = 00 # Nr. della minor version.<br />

# BASH_VERSINFO[2] = 14 # Nr. del patch level.<br />

# BASH_VERSINFO[3] = 1 # Nr. della build version.<br />

# BASH_VERSINFO[4] = release # Stato della release.<br />

# BASH_VERSINFO[5] = i386-redhat-linux-gnu # Architettura.<br />

95

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

Saved successfully!

Ooh no, something went wrong!