Daniel Cartron wrote:
> Le mercredi 20 août 2008, Laurent Menase a écrit :
>> ca doit gere a peut pres tous les cas:
> 
> Beuh ça marche tjs pas, désolé... J'ai commencé par virer les espaces en 
> trop, 
> ça lui paisait pas.. Et maintenant il me dit 
> 
> ./testdir.sh: line 12: syntax error near unexpected token `then'
> ./testdir.sh: line 12: `                        then'
> 
> la ligne 12 c'est le 3me then, celui de la 2me sous boucle...
> 

C est marrant sur ma debian ou mon hpux ca marche impec
$ cat /usr/bin/truc
#!/bin/sh
myscriptpath=$(dirname $0)
if [ ! -z "${myscriptpath##/*}"  ]
then
     if [ !  -z "${0##./}"  ]
     then
         myscriptname=$(which $0)
         myscriptpath=$(dirname $myscriptname)
     fi
     if  [   -z "${myscriptpath##./}" -o ! -z "${myscriptpath##/*}"   ]
     then
         myscriptpath="$PWD/${myscriptpath#./}"
     fi
     myscriptpath="${myscriptpath%/.}"
fi

echo $myscriptpath
$ cd /usr/bin
$ truc
/usr/bin
$ cd /usr
$ bin/truc
/usr/bin
$ cd $HOME
$ truc
/usr/bin


envoie le fichier en attachement
_________________________________
Linux mailing list
[email protected]
http://lists.parinux.org/mailman/listinfo/linux

Répondre à