瀏覽代碼

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

Matthew Wang 11 年之前
父節點
當前提交
00d946cb7e
共有 1 個檔案被更改,包括 5 行新增3 行删除
  1. 5
    3
      src/cdiff.py

+ 5
- 3
src/cdiff.py 查看文件

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