0

What is wrong with this? I can't seem to assign anything to the $SITE var. The "rm"s don't work either. Am I concatenation the command and var wrong?

newsite () { local SITE = $1; if [ -z "$1" ]; then # Is parameter #1 zero length? echo 'Please give the site a name' read = SITENAME; $SITE = $SITENAME fi git clone git://mydomain/site_template.git $SITE echo "New site has been created called: \"$SITE\"." rm -rf $SITE"/.git"; rm $SITE"/README.txt"; return 0 } 

2 Answers 2

1

take care of whitespaces:

local SITE=$1 

also:

read SITENAME 

and

SITE=$SITENAME 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks yi_H. My problem was that "$SITE = $SITENAME;" in not correct. I needed to remove the "$" from "$SITES"
@Pardoner, you also cannot have spaces around the = -- this is fundamental to sh syntax.
0
function newsite { SITE=$1; if [ -z "$1" ] then echo 'Please give the site a name'; read = SITENAME; $SITE = $SITENAME; fi git clone git://mydomain/site_template.git $SITE echo "New site has been created called: \"$SITE\"." rm -rf $SITE"/.git"; rm $SITE"/README.txt"; return 0 } 

1 Comment

Also, how would I check to see if the repo was successfully cloned before I remove anything?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.