[gull] Truc et astuces: Jouons avec ``eval'' et bash

Gregoire Galland gregoire.galland at hispeed.ch
Sat Oct 6 11:33:01 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Félix Hauri wrote:
> Sans commentaires, juste un saut de ligne avant les commandes.
>
> $ echo $str
>
>
> $ str=$(eval echo -e $(printf '\\\\%o,' $(seq 65 90)) |
>         sed 's/^/{/;s/,$/}/')
>
> $ echo $str
> {A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}
>
> $ eval echo $str
> A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
>
> $ eval "printf '%s\n' $str\ $str\ $str" | wc
>   17576   52728  105456
>
> $ echo 'a=26^3;a;a*3;a*6' | bc -l | xargs printf "%7d %7d %7d\n"
>   17576   52728  105456
>
> $ eval "printf '%s\n' $str\ $str\ $str\ $str"
>
Heu... pas tout compris à ton script, il me fait des erreur d'exécution.

Pour le problème dont je t'avais parlé l'autre soir (problème
d'exécution de commande dans un script), j'ai trouvé le bug: je
manipulais la variable d'environnement $IFS, et c ça qui foutait la merde.

A+

Greg

- --
Galland Grégoire
Ch. de la Brume 4
1110 Morges
Tél    : 021 622 07 37
Mobile : 079 511 30 07
SIP    : 1016 at voip.saitis.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHB1ZNI8gmGeMTr0sRAv4OAJ9YpCUxu3E/Ttfrdjdnulu49KDnrACaAo4W
eqI0h5WDcjXJXV0mC2OGbuw=
=XrsQ
-----END PGP SIGNATURE-----

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3447 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://forum.linux-gull.ch/pipermail/gull/attachments/20071006/51869739/attachment.bin>


More information about the gull mailing list