Expand args to absolute paths before checking their validity.
This fixes a bug in which the validity of FROM_DIR and TO_DIR were checked before ~ and relative paths in those arguments were expanded, sometimes this could cause dotfilemanager to complain that a valid path was invalid. Expand the paths and _then_ check their validity. You can now just do `dotfilemanager tidy` (with no further arguments) to tidy up symlinks in your homedir, and `dotfilemanager report` or `dotfilemanager link` to report on or make links from ~ into ~/.dotfiles.
This commit is contained in:
parent
bc6bd6c777
commit
ec76c782c6
@ -171,11 +171,11 @@ if __name__ == "__main__":
|
||||
FROM_DIR = sys.argv[2]
|
||||
except IndexError:
|
||||
FROM_DIR = '~'
|
||||
FROM_DIR = os.path.abspath(os.path.expanduser(FROM_DIR))
|
||||
if not os.path.isdir(FROM_DIR):
|
||||
print "FROM_DIR %s is not a directory!" % FROM_DIR
|
||||
print usage()
|
||||
sys.exit(2)
|
||||
FROM_DIR = os.path.abspath(os.path.expanduser(FROM_DIR))
|
||||
if ACTION == 'tidy':
|
||||
tidy(FROM_DIR)
|
||||
else:
|
||||
@ -183,11 +183,11 @@ if __name__ == "__main__":
|
||||
TO_DIR = sys.argv[3]
|
||||
except IndexError:
|
||||
TO_DIR = os.path.join('~','.dotfiles')
|
||||
TO_DIR = os.path.abspath(os.path.expanduser(TO_DIR))
|
||||
if not os.path.isdir(TO_DIR):
|
||||
print "TO_DIR %s is not a directory!" % TO_DIR
|
||||
print usage()
|
||||
sys.exit(2)
|
||||
TO_DIR = os.path.abspath(os.path.expanduser(TO_DIR))
|
||||
if ACTION == 'link':
|
||||
link(FROM_DIR,TO_DIR)
|
||||
elif ACTION == 'report':
|
||||
|
Loading…
Reference in New Issue
Block a user