Execute-Befehl als string in der Bash

Teste ich ein kurzes bash-Skript. Ich möchte zum ausführen einer Zeichenfolge als Befehl.

#!/bin/bash

echo "AVR-GCC"
$elf=" main.elf"
$c=" $main.c"
$gcc="avr-gcc -mmcu=atmega128 -Wall -Os -o $elf$c"
eval $gcc
echo "AVR-GCC done"

Ich weiß, es ist hässlich und alle, aber sollte es nicht ausführen, die avr-gcc-Befehl?
Die Fehler sind die folgenden:

./AVR.sh: line 4: = main.elf: command not found
./AVR.sh: line 5: = .c: command not found
./AVR.sh: line 6: =avr-gcc -mmcu=atmega128 -Wall -Os -o : command not found
Sie sollten keine dollar-Zeichen linken Seite der Zuweisung: z.B. elf=" main.elf" nicht elf=" main.elf

InformationsquelleAutor erbal | 2013-11-05

Schreibe einen Kommentar