Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Shell-Simulator 0.0.2
- by Felix Oesterreicher
- 07-07-2012
- '''
- dir=["home","felix"] # directory to start with
- x = ""
- while True:
- # Set the working directory
- wd= ""
- if dir==[]:
- wd="/"
- else:
- for i in range(0,len(dir),1):
- wd+="/"+dir[i]
- # Get the command ( x - raw command , y - list of args )
- x= input (wd+"$ ")
- y= x.split()
- ''' the possible commands '''
- # exit
- if y[0]=="exit":
- break
- # cd
- elif y[0]=="cd":
- if len(y)<=1:
- dir=["home","felix"]
- continue
- if y[1][0]=="/":
- dir=y[1].split("/")
- del dir[0]
- elif y[1]=="..":
- if not dir==[]:
- del dir[-1]
- elif y[1]==".":
- pass
- else:
- dir.append(y[1])
- # pwd
- elif y[0]=="pwd":
- print(wd)
- # command not found
- else:
- print ("Command not found.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement