Browse Source

Use return in main(), let prog has one exit point

Matthew Wang 11 years ago
parent
commit
00d946cb7e
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/cdiff.py

+ 5
- 3
src/cdiff.py View File

541
             sys.stderr.write(('*** Not in a supported workspace, supported '
541
             sys.stderr.write(('*** Not in a supported workspace, supported '
542
                               'are: %s\n\n') % ', '.join(supported_vcs))
542
                               'are: %s\n\n') % ', '.join(supported_vcs))
543
             parser.print_help()
543
             parser.print_help()
544
-            sys.exit(1)
544
+            return 1
545
     else:
545
     else:
546
         diff_hdl = sys.stdin
546
         diff_hdl = sys.stdin
547
 
547
 
550
 
550
 
551
     # Don't let empty diff pass thru
551
     # Don't let empty diff pass thru
552
     if not stream:
552
     if not stream:
553
-        return
553
+        return 0
554
 
554
 
555
     if diff_hdl is not sys.stdin:
555
     if diff_hdl is not sys.stdin:
556
         diff_hdl.close()
556
         diff_hdl.close()
566
         # pipe out stream untouched to make sure it is still a patch
566
         # pipe out stream untouched to make sure it is still a patch
567
         sys.stdout.write(''.join(stream))
567
         sys.stdout.write(''.join(stream))
568
 
568
 
569
+    return 0
570
+
569
 
571
 
570
 if __name__ == '__main__':
572
 if __name__ == '__main__':
571
-    main()
573
+    sys.exit(main())
572
 
574
 
573
 # vim:set et sts=4 sw=4 tw=80:
575
 # vim:set et sts=4 sw=4 tw=80: