Argumentos em Shell Scripts (Bourne Shell) (3)
Colaboração: Rubens Queiroz de Almeida
Data de Publicação: 02 de Junho de 1997
$?
Código de retorno do último comando executado. Códigos de retorno iguais a zero indicam que o programa conseguiu executar sua tarefa com sucesso, ao passo que valores diferentes indicam algum tipo de erro. Este valor pode ser setado de dentro de uma shell através da diretiva "exit".
Por exemplo:
if [ $? -eq 0 ]; then mv file file.old else mv file file.err fi
No exemplo acima é testado o resultado do último comando executado. Se for 0 (tudo ok) o arquivo chamado file é renomeado para file.old. Caso algum erro tenha ocorrido, o arquivo file é renomeado para file.err.
Dica Humorística :-)
ICONS Help you get the thought out!
Are you afraid that you come across differently electronically than you do on paper, over the phone or in person? The answer may be icons! The icons listed below can help you express those no-verbal signals that are all but impossible to express over the net.
:-) Smiling :-( Frowning '-) Wink ;-) Sardonic incredulity %-) Drunk with laughter :-" Pursing lips :-O Wow! :-| Grim := | Baboon :-v Speaking :-V Shouting :-W Speak with forked tongue :-r Sticking tongue out :-* Oops! (covering mouth with hand) :-T Keeping a straight face (tight-lipped) :-D Said with a smile :-x Kiss :-c Real unhappy :-C Just totally unbelieving! (Jaw dropped) :-B Drooling :-, Smirk :-|| Anger :-$ Uncertainty :-# Mouth zipped :-& Tangled up tongue :-@ Swearing