Ho il seguente script:
#!/bin/bash
set -x
if :; then
echo a
fi
Se corro bash /tmp/file, aviene ripetuto, ma se corro source /tmp/file, ottengo:
bash: /tmp/test: line 6: syntax error: unexpected end of file
L'output:
knezi@holly tmp]$set -x; source /tmp/test; set +x
+ source /tmp/test
++ set -x
bash: /tmp/test: line 6: syntax error: unexpected end of file
+ set +x
knezi@holly tmp]$set -x; command source /tmp/test; set +x
+ set -x
+ command source /tmp/test
+ source /tmp/test
++ set -x
bash: /tmp/test: line 6: syntax error: unexpected end of file
+ set +x
knezi@holly tmp]$bash -c "source /tmp/test"
+ bash -c 'source /tmp/test'
++ :
++ echo a
a
knezi@holly tmp]$od -c /tmp/test
0000000 # ! / b i n / b a s h \n s e t
0000020 - x \n i f : ; t h e n \n \t e
0000040 c h o a \n f i \n
0000051
Output dei comandi shopt -pe set -o: http://pastebin.com/bsqc8aru
Uscita di set: http://pastebin.com/S9KpqZAL
declare -fp non produce nulla.
Ho pensato che sourcefa lo stesso di bash, ma invece di iniziare una nuova sessione esegue il codice in quello corrente. Qualcuno può spiegarmi questo errore?
Corro bash GNU bash, versione 4.2.53 (1) -release (x86_64-redhat-linux-gnu).
$BASH_ENVset?
bash -ctua domanda. Quindi, mostraci il contenuto del tuo ~/.bashrcfile, probabilmente c'è qualcosa che sta rovinando le cose.