# HG changeset patch # User David Barts # Date 1559278526 25200 # Node ID ccd52fb45cff033cbc2ee2d4ebb255bc9800df68 # Parent 15f665a620a2d9b078abf4d836b38c8493a59c6e Fix some bugs. diff -r 15f665a620a2 -r ccd52fb45cff install-static --- a/install-static Thu May 30 21:44:26 2019 -0700 +++ b/install-static Thu May 30 21:55:26 2019 -0700 @@ -34,7 +34,15 @@ spath = os.path.join(source, entry) tpath = os.path.join(target, entry) stype = os.stat(spath).st_mode + try: + ttype = os.stat(tpath).st_mode + except FileNotFoundError: + ttype = None if S_ISREG(stype): + if ttype is not None and not S_ISREG(ttype): + sys.stderr.write( + "{0}: {1!r} not a file\n".format(MYNAME, tpath)) + sys.exit(1) if args.move: print("mv", repr(spath), repr(tpath)) shutil.move(spath, tpath) @@ -42,7 +50,11 @@ print("cp", repr(spath), repr(tpath)) copyfile(spath, tpath) elif S_ISDIR(stype): - if not os.path.isdir(tpath): + if ttype is not None and not S_ISDIR(ttype): + sys.stderr.write( + "{0}: {1!r} not a directory\n".format(MYNAME, tpath)) + sys.exit(1) + if not S_ISDIR(ttype): print("mkdir", repr(tpath)) os.mkdir(tpath) copydir(spath, tpath, False)