rcmain 970 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # rcmain
  2. if(~ $#home 0) home=/
  3. if(~ $#ifs 0) ifs='
  4. '
  5. if(~ $rcname ?.out) {
  6. oldprompt=$prompt
  7. prompt=('broken! ' ' ')
  8. }
  9. if not {
  10. if (~ $#oldprompt 1 2)
  11. prompt=$oldprompt
  12. switch($#prompt){
  13. case 0
  14. prompt=('% ' ' ')
  15. case 1
  16. prompt=($prompt ' ')
  17. }
  18. }
  19. if(flag p) path=/bin
  20. if not{
  21. finit # import functions from env
  22. if(~ $#path 0) path=(. /bin)
  23. }
  24. fn sigexit
  25. fn rclogin {
  26. if(flag l) {
  27. if(! ~ $service rx && test ! -f /_fs_main)
  28. cat /cfg/$sysname/warning >[2]/dev/null
  29. if(/bin/test -r $home/lib/profile)
  30. . $home/lib/profile
  31. }
  32. status=''
  33. }
  34. if(! ~ $#cflag 0){ # rc -c cmd
  35. rclogin
  36. fn rclogin
  37. eval $cflag
  38. }
  39. if not if(flag i){ # interactive shell
  40. rclogin
  41. fn rclogin
  42. if(! ~ $#* 0)
  43. . $* # source any arguments
  44. . -i '#d/0' # read stdin interactively
  45. }
  46. # else non-interactive use
  47. if not if(~ $#* 0) {
  48. fn rclogin
  49. . '#d/0' # read stdin non-interactively
  50. }
  51. if not{
  52. status=''
  53. fn rclogin
  54. . $* # source any arguments
  55. }
  56. exit $status