Is there a way to use os.chdir() to go to relative user folder?
I'm making a bash and the only issue I found is the cd ~
, arg[0]
is undefined since I'm using this cd functions:
def cd(args):
os.chdir(args[0])
return current_status
Which I want to change to
def cd(args):
if args[0] == '~':
os.chdir('/home/')
# Here I left it to /home/ since I don't know how
# to get the user's folder name
else:
os.chdir(args[0])
return current_status