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

Re: (solucionado) Re: [OT] Una de Bash



2011/8/15 Camaleón <noelamac@gmail.com>:
> El Mon, 15 Aug 2011 14:10:53 -0300, Matías Bellone escribió:
>
>> 2011/8/15 Camaleón <noelamac@gmail.com>:
>>> Hola,
>>>
>>> El otro día me di cuenta de que un script que tengo en bash no
>>> funcionaba al ejecutarlo en wheezy (en lenny corre sin problemas).
>>>
>>> hpc03@stt300:~/Escritorio$ echo $SHELL /bin/bash
>>>
>>> hpc03@stt300:~/Escritorio$ cat test.sh #!/bin/bash
>>> declare -a Test=("elemento 1" "elemento 2"); echo ${Test[@]}
>>>
>>> hpc03@stt300:~/Escritorio$ sh test.sh test.sh: 2: Syntax error: "("
>>> unexpected
>>>
>>> hpc03@stt300:~/Escritorio$ declare -a Test=("elemento 1" "elemento 2");
>>> echo ${Test[@]} elemento 1 elemento 2
>>>
>>> ¿Qué está pasando?
>>>
>>>
>> probá "ls -l /bin/sh"
>
> Sí, apunta a dash... pero la variable de entorno $SHELL me dice que es
> bash :-?

Porque $SHELL te dice qué shell estás ejecutando en ese momento, no
cuál vas a ejecutar después.

Si quieres evitar este tipo de problemas y quieres que tu script
funcione en cualquier shell, invetiga sobre "bashisms" (cosas que sólo
funcionan en bash pero no en otros shells).

Saludos,
Toote
-- 
Web: http://www.enespanol.com.ar


Reply to: