shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Re: [shell-script] Problemas com perda de valor de uma variável


From: mop
Subject: Re: Re: Re: [shell-script] Problemas com perda de valor de uma variável
Date: Wed, 07 May 2008 15:01:53 -0300

MINHA RESPOSTA:

Uma das finalidades do bash é emular o velho sh, bom para os 
tradicionalistas e conservadores. :)
Geralmente via soft link.


$ sh temp.sh  
t=
temp.sh: line 6: syntax error near unexpected token `<'
temp.sh: line 6: `read t< <(date)'

$ sh < temp.sh                                                       
t=
sh: line 6: syntax error near unexpected token `<'
sh: line 6: `read t< <(date)'

$ bash < temp.sh                                                     
t=
t=Wed May 7 14:44:46 hrN 2008
GNU bash, version 3.2.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ 


Confirmando ao usar o velho link sh para o bash:
$ sh                                                                 

$ t=;t=$(ls -1d tw*|{ while read x;do echo $x;done;});echo "|$t|" 
|twin-0.4.6
twm.log|
# funcionou \o/  (eu tô fora!, mas é mais portável.)

$ t=;while read x;do echo $x;done< <(ls -1d tw*);echo "|$t|"         
sh: syntax error near unexpected token `<'
$ 
# RATIFICADO!

$ $0
$
# IDEM!

Bem, chega de história por hoje. Fui!




------------------------------------------
|From: mop
|
|Ok, confirmei!
|Antes de eu tentar entender,
|==> por que você usa esse "estilo histórico" de chamada de script?
|
|Viu como é boa essa do modular. :)
|O problema continua o mesmo, mas ele ficou pequeno. :))
|
|
------------------------------------------
>From: ednei
>
>fiz assim:( coloquei num arquivo chamado temp.sh )
>
>t=;
>date|read t;
>echo t=$t
>
>t=;
>read t< <(date)
>echo t=$t
>$0 --version
>
>
>
>saída:
>
>[ednei@localhost projeto]$ sh temp.sh
>t=
>temp.sh: line 6: syntax error near unexpected token `<'
>temp.sh: line 6: `read t< <(date)'
>[ednei@localhost projeto]$
>
>
>Se eu fizer no terminal, funciona:
>
>
>[ednei@localhost projeto]$ read t< <(date)
>[ednei@localhost projeto]$ echo $t
>Wed May 7 14:28:21 BRT 2008
>
>
>
>
>Não entendo! ( boa essa do modular =D )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]