local a={...}local b=1;local c={createHome=true}while b<=#a do local d=a[b]if d=="-p"then b=b+1;c.password=a[b]elseif d=="-g"then b=b+1;c.gid=tonumber(a[b])elseif d=="-d"then b=b+1;c.homedir=a[b]elseif d=="-s"then b=b+1;c.shell=a[b]elseif d=="-M"then c.createHome=false elseif d:sub(1,1)~="-"then c.username=d else print("useradd: unknown option: "..d)return end;b=b+1 end;if not c.username then print("Usage: useradd [-p password] [-g gid] [-d homedir] [-s shell] [-M] ")syscall.exit(1)return end;local e=c.password;if not e then printInline("New password: ")e=""while true do local f=syscall.read(0)if not f or f==""then elseif f=="\n"then syscall.write(1,"\n")break elseif f=="\b"then if#e>0 then e=e:sub(1,-2)syscall.write(1,"\b \b")end else e=e..f;syscall.write(1,"*")end end;printInline("Confirm password: ")local g=""while true do local f=syscall.read(0)if not f or f==""then elseif f=="\n"then syscall.write(1,"\n")break elseif f=="\b"then if#g>0 then g=g:sub(1,-2)syscall.write(1,"\b \b")end else g=g..f;syscall.write(1,"*")end end;if e~=g then print("useradd: passwords do not match")syscall.exit(1)return end end;local h,i=syscall.newuser(c.username,e,c.gid,c.homedir,c.shell or"/bin/hysh")if not h then print("useradd: "..tostring(i))syscall.exit(1)return end;if c.createHome then local j=c.homedir or"/home/"..c.username;local k,l=pcall(syscall.mkdir,j)if not k then print("useradd: warning: could not create home "..j..": "..tostring(l))end end;print("useradd: created user '"..c.username.."' with uid="..tostring(h))