Index: trunk/dasscm/dasscm
===================================================================
--- trunk/dasscm/dasscm	(revision 251)
+++ trunk/dasscm/dasscm	(revision 252)
@@ -24,4 +24,7 @@
 #
 
+my $RETURN_OK  = 0;
+my $RETURN_NOK = 1;
+
 # file to store permissions
 my $permissions_file = "/etc/permissions.d/dasscm.permission_backup";
@@ -29,4 +32,6 @@
 # documentation file (for usage)
 my $doc_file = "/usr/share/doc/packages/dasscm/dasscm_howto.txt";
+
+my @COMMANDS_REQUIRE_WRITE = ( 'add', "commit" );
 
 # configuration file
@@ -38,5 +43,4 @@
 my $DASSCM_CHECKOUT_USERNAME;
 my $DASSCM_CHECKOUT_PASSWORD;
-
 
 # current directory at program start
@@ -180,20 +184,20 @@
     if ($verbose) { print "DASSCM_REPO: " . $DASSCM_REPO . "\n"; }
 
-
     #
     # subversion checkout user
     #
-    if( ! $DASSCM_CHECKOUT_USERNAME ) {
-        fatalerror( 
+    if ( !$DASSCM_CHECKOUT_USERNAME ) {
+        fatalerror(
             "variable DASSCM_CHECKOUT_USERNAME is not defined.",
-            "Use file $config_file to configure it." );
-    }
-
-    if( ! $DASSCM_CHECKOUT_PASSWORD ) {
-        fatalerror( 
+            "Use file $config_file to configure it."
+        );
+    }
+
+    if ( !$DASSCM_CHECKOUT_PASSWORD ) {
+        fatalerror(
             "variable DASSCM_CHECKOUT_PASSWORD is not defined.",
-            "Use file $config_file to configure it." );
-    }
-    
+            "Use file $config_file to configure it."
+        );
+    }
 
     #
@@ -220,6 +224,14 @@
         # otherwise USER can be used
         if ( "$USER" eq "root" ) {
-            if ( ( not $DASSCM_USERNAME ) and ( $command ne "login" ) ) {
-                fatalerror( "Envirnonment variable DASSCM_USERNAME not set.", "Set DASSCM_USERNAME to your subversion user account or", "use 'dasscm login'" );
+            if (    ( not $DASSCM_USERNAME )
+                and ( grep { m|^$command$| } @COMMANDS_REQUIRE_WRITE ) )
+            {
+
+                #( $command ne "login" ) and ( $command ne "status" ) ) {
+                fatalerror(
+                    "Envirnonment variable DASSCM_USERNAME not set.",
+                    "Set DASSCM_USERNAME to your subversion user account or",
+                    "use 'dasscm login'"
+                );
             }
             $svnOptions .= " --no-auth-cache ";
@@ -376,6 +388,4 @@
 }
 
-
-
 sub svn_check_credentials( $$;$$ )
 {
@@ -383,5 +393,5 @@
     my $password = shift;
 
-    # check silently are allow user interaction? 
+    # check silently are allow user interaction?
     my $interactive = shift || 0;
 
@@ -389,6 +399,4 @@
     #   (do not exit for 'init')
     my $fatalerror = shift || 1;
-
-
 
     print "checking credentials ";
@@ -413,15 +421,18 @@
 
     my $rc_update;
-    if( $interactive ) {
-        $rc_update = run_interactive( "$SVN ls --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY" );
+    if ($interactive) {
+        $rc_update =
+          run_interactive(
+            "$SVN ls --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
+          );
     } else {
         ( $rc_update, my @result ) =
-        run_command(
+          run_command(
             "$SVN ls --non-interactive --no-auth-cache --username $username --password $password $DASSCM_SVN_REPOSITORY"
-        );
-    
+          );
+
         if ( $rc_update != 0 ) {
             print "\n", @result;
-            if( $fatalerror ) {
+            if ($fatalerror) {
                 fatalerror();
             }
@@ -433,6 +444,4 @@
     return $rc_update == 0;
 }
-
-
 
 sub svn_update( ;$ )
@@ -562,5 +571,6 @@
 
     # checking checkout username/password
-    svn_check_credentials( $DASSCM_CHECKOUT_USERNAME, $DASSCM_CHECKOUT_PASSWORD );
+    svn_check_credentials( $DASSCM_CHECKOUT_USERNAME,
+        $DASSCM_CHECKOUT_PASSWORD );
     print "checkout access okay\n";
 
@@ -594,5 +604,5 @@
     my $retcode =
       run_interactive(
-        "cd $DASSCM_LOCAL_REPOSITORY_BASE; $SVN checkout $svnCheckoutCredentials $svnOptions $DASSCM_SVN_REPOSITORY; touch $permissions_file"
+        "cd $DASSCM_LOCAL_REPOSITORY_BASE; $SVN checkout $svnCheckoutCredentials $svnOptions $DASSCM_SVN_REPOSITORY; mkdir -p `dirname $permissions_file`; touch $permissions_file"
       );
 }
@@ -782,4 +792,8 @@
     check_env();
 
+    # return code for the shell
+    # default: error
+    my $return_code = $RETURN_NOK;
+
     #
     # update local repository
@@ -833,7 +847,10 @@
     } else {
         print "no modified files found in $dir\n";
+        $return_code = $RETURN_OK;
     }
 
     print "\n";
+
+    return $return_code;
 }
 
@@ -891,4 +908,5 @@
 #
 
+my $return_code      = $RETURN_OK;
 my $number_arguments = @ARGV;
 
@@ -966,6 +984,6 @@
         diff(@ARGV);
     } elsif ( (m/status/i) || (m/st/i) ) {
-        $command = "status";
-        status(@ARGV);
+        $command     = "status";
+        $return_code = status(@ARGV);
     } elsif (m/permissions/i) {
         $command = "permissions";
@@ -975,4 +993,5 @@
         usage();
         check_env();
+        $return_code = $RETURN_NOK;
     }
 
@@ -982,3 +1001,6 @@
     # activate
     # rm
-}
+
+}
+
+exit $return_code;
