This is my very first Bash script that does something real. I'm here to learn, so please tell me if and how this can be done better.#!/bin/sh# Daniele Brugnara# October - 2013if [ -k $1 ]; then        echo Error! You must pass a repository name!        exit 1fiSVN_PATH=/var/lib/svncurrPath=$(pwd)cd $SVN_PATHsvnadmin create $1chown -R www-data:www-data $1cd $currPathecho Done! Remember to set valid user permission in authz file.
New svn repository script
bash
If the first argument to your script contains a space, then you get an error message:$ ./cr32076.sh my repository./cr32076.sh: line 6: [: my: binary operator expectedTo avoid this, put quotes around the variable $1, like this:if [ -k $1 ]; thenThe man page for [ says:-k file       True if file exists and its sticky bit is set.is this really what you mean? It seems more likely that you want the -z option:-z string     True if the length of string is zero.You remember the current directory in a variable:currPath=$(pwd)and then later change to it:cd $currPathbut this will go wrong if the current directory has a space in its name:$ pwd/Users/gdr/some directory$ currPath=$(pwd)$ cd $currPathbash: cd: /Users/gdr/some: No such file or directoryTo avoid this, put quotes around the variable, like this:cd $currPathIf you want to change directory temporarily and change back again, then instead of writingcurrPath=$(pwd)   # remember old directorycd $SVN_PATH    # change to new directory# do some stuffcd $currPath    # go back to old directoryyou can use a subshell:(    cd $SVN_PATH    # change to new directory    # do some stuff        ) # old directory is automatically restored when subshell exitsBut in this script, there's no need to change directory back again, because after you go back all you do is echo Done! ... and it doesn't matter what directory you do that in.In fact, there's no need to change directory at all, because instead ofSVN_PATH=/var/lib/svncurrPath=$(pwd)cd $SVN_PATHsvnadmin create $1chown -R www-data:www-data $1cd $currPathyou could writeSVN_PATH=/var/lib/svn/$1svnadmin create $SVN_PATHchown -R www-data:www-data $SVN_PATH