diff --git a/build/simulink_codegen/writegitinfoheader.m b/build/simulink_codegen/writegitinfoheader.m
index 77bb1b5c5c6d7115b23b5f1401da7c274d111eec..8c85f6c74979f701279775e0d8687fe65825b74c 100644
--- a/build/simulink_codegen/writegitinfoheader.m
+++ b/build/simulink_codegen/writegitinfoheader.m
@@ -117,10 +117,11 @@ function writegitinfoheader()
       cfg=Simulink.fileGenControl('getConfig');
       codegenfolder=cfg.CodeGenFolder;
       cleancmd = ['rm -f ' codegenfolder '/*.so'];
-      [~,result]  = system(cleancmd);
+      [status,result]  = system(cleancmd);
       
-      if result~=0cleancmd
+      if result~=0
           warning('Build folder could not be cleaned properly with the command: %s',cleancmd);
+          status
       end
    catch ME
        warning('Exception cleaning expcode build folder %s', codegenfolder);