Marc Reichelt: (BASH) Mehrere Bedingungen für if? Verzeichnis des Skripts?

Beitrag lesen

Hallo Mathias,

Offenbar nicht, siehe „compound operators“ auf dieser Seite.

Doch, ich hab's jetzt hinbekommen! :-)

Das Skript sieht derzeit so aus:

<code file="createskin.sh">
#!/bin/bash

global options

path to MTASC binary

binarymtasc="mtasc"

path to ActionScript classes for MTASC

classpath="/usr/local/bin/std/"

path to swfmill binary

binaryswfmill="swfmill"

MTASC compile flags

mtascflags="-version 6 -strict -wimp -header 600:400:31"

temporary file for classes compiled by MTASC

tempcompilation="compilation.temp.swf"

input file MTASC

inputmtasc="Skin.as"

input file swfmill

inputswfmill="swfmill.xml"

change to temp directory - this is the only directory where we will work

cd ../temp/

check parameter

if [ "$1" != "" ] && [ -d "../skins/$1/" ] && [ -f "../skins/$1/$inputmtasc" ] && [ -f "../skins/$1/$inputswfmill" ]
then
 # seems to be ok
else
 echo "usage: $0 <name of skin>"
 exit 1
fi

execution of commands

copy all skin files into this temp directory

cp -rf ../skins/$1/* ./

create temporary file with compilation created by MTASC

$binarymtasc -cp $classpath -cp ../code/ $mtascflags $inputmtasc -swf $tempcompilation

create skin with swfmill

$binaryswfmill simple $inputswfmill "../skins/$1.swf"

delete temporary files

rm -rf *

exit 0

</code>

Derzeit ist die letzte Zeile - das Löschen der temporären Dateien - noch auskommentiert, da der Befehl sich, wenn er im falschen Ordner aufgerufen wird, ziemlich gravierend auswirken könnte. Genau dazu brauche ich nämlich eine Anweisung, dass das Skript auch garantiert im richtigen Ordner aufgerufen wird.

Hmm, außerdem habe ich noch ein kleines Problem: Im temp-Ordner gibt es eine Datei "IMPORTANT", die natürlich nicht gelöscht werden soll.
Gibt es dafür einen Shell-Ausdruck, damit diese Datei nicht mit gelöscht wird? Ich tippe auf einen regulären Ausdruck...

Grüße

Marc Reichelt || http://www.marcreichelt.de/

--
Linux is like a wigwam - no windows, no gates and an Apache inside!
Selfcode: ie:{ fl:| br:> va:} ls:< fo:} rl:( n4:( ss:) de:> js:| ch:? sh:| mo:) zu:)