Argumentos em Shell Scripts (Bourne Shell) (2)
Colaboração: Rubens Queiroz de Almeida
Data de Publicação: 01 de Junho de 1997
Número de argumentos fornecidos. Constitui uma norma de boa
programação verificar este valor no início da shell e emitir
mensagem de erro caso incorreto.
if [ $# -ne 2 ]; then
echo 1>&2 Sintaxe: $0 in out
No exemplo acima, se não forem fornecidos dois argumentos é exibida
uma mensagem de erro para o usuário e é setado o código de retorno
com o valor 1 para indicar que houve um erro de processamento.
Dica Humorística :-)
TO MY DARLING HUSBAND:
I am sending you this letter via this BBS
communications thing, so that you will be sure to
read it. Please forgive the deception, but I
thought you should know what has been going on at
home since your computer entered our lives two
years ago. The children are doing well. Tommy is
seven now and is a bright, handsome boy. He has
developed quite an interest in the arts. He drew
a family portrait for a school project, all the
figures were good, and the back of your head is
very realistic. You should be very proud of him.
Little Jennifer turned three in September. She
looks a lot like you did at that age. She is an
attractive child and quite smart. She still
remembers that you spent the whole afternoon with
us on her birthday. What a grand day for Jenny,
despite the fact that it was stormy and the
electricity was out.
I am doing well. I went blonde about a year ago,
and discovered that it really is more fun!
George, I mean, Mr. Wilson the department head,
has, uh, taken an interest in my career and has
become a good friend to us all.
I discovered that the household chores are much
easier since I realized that you didn't mind being
vaccumed but that feather dusting made you sneeze.
The house is in good shape. I had the living room
painted last spring; I'm sure you noticed it. I
made sure that the painters cut holes in the drop
sheet so you wouldn't be disturbed.
Well, my dear, I must be going. Uncle George, uh,
Mr. Wilson, I mean, is taking us all on a ski trip
and there is packing to do. I have hired a
housekeeper to take care of things while we are
away, she'll keep things in order, fill your
coffee cup and bring your meals to your desk, just
the way you like it. I hope you and the computer
will have a lovely time while we are gone. Tommy,
Jenny, and I will think of you often. Try to
remember us while your disks are booting.