ray@GIBBS.PHYSICS.PURDUE.EDU (Ray Moody) (08/04/89)
I fixed a bug in polite_directory_format: If $HOME was /a/ray, the directory /a/raymond would be politely printed as ~mond. I also have a few enhancements that make bash work better when you are root: I have added stuff to decde_prompt_string so that "\$" prints "$" unless you are root, and then it prints "#". I have changed the default prompt to make use of this feature. (This seemed to be a better approach than picking a default prompt at startup -- now I can use the same PS1 for both root and normal shells). I have changed polite_directory_format so that "/usr/bin" will not be politely printed as "~usr/bin" when $HOME is /. (This last one is really a bugfix and not an enhancement.) Ray ------------------------------------------------------------------------------- RCS file: RCS/builtins.c,v retrieving revision 1.2.1.1 diff -c -r1.2.1.1 builtins.c *** /tmp/,RCSt1005909 Thu Aug 3 18:17:49 1989 --- builtins.c Thu Aug 3 17:55:45 1989 *************** *** 2680,2686 char *home = get_string_value ("HOME"); int l = home ? strlen (home) : 0; ! if (l && strncmp (home, name, l) == 0) { strcpy (tdir + 1, name + l); tdir[0] = '~'; return (tdir); --- 2680,2686 ----- char *home = get_string_value ("HOME"); int l = home ? strlen (home) : 0; ! if (l > 1 && strncmp (home, name, l) == 0 && name[strlen (name) - 1] == '/') { strcpy (tdir + 1, name + l); tdir[0] = '~'; return (tdir); =================================================================== RCS file: RCS/Makefile,v retrieving revision 1.2.1.1 diff -c -r1.2.1.1 Makefile *** /tmp/,RCSt1005909 Thu Aug 3 18:17:57 1989 --- Makefile Thu Aug 3 17:46:07 1989 *************** *** 93,99 PROGRAM = bash # The default primary and secondary prompts. ! PPROMPT = '"${PROGRAM}$$ "' SPROMPT = '"${PROGRAM}>"' # The group of configuration flags. These are for shell.c --- 93,99 ----- PROGRAM = bash # The default primary and secondary prompts. ! PPROMPT = '"${PROGRAM}\\$$ "' SPROMPT = '"${PROGRAM}>"' # The group of configuration flags. These are for shell.c =================================================================== RCS file: RCS/shell.c,v retrieving revision 1.2 diff -c -r1.2 shell.c *** /tmp/,RCSt1005909 Thu Aug 3 18:17:58 1989 --- shell.c Thu Aug 3 17:46:03 1989 *************** *** 67,73 char *the_current_maintainer = MAINTAINER; #ifndef PPROMPT ! #define PPROMPT "bash$ "; #endif char *primary_prompt = PPROMPT; --- 67,73 ----- char *the_current_maintainer = MAINTAINER; #ifndef PPROMPT ! #define PPROMPT "bash\\$ "; #endif char *primary_prompt = PPROMPT; =================================================================== RCS file: RCS/parse.y,v retrieving revision 1.2.1.1 diff -c -r1.2.1.1 parse.y *** /tmp/,RCSt1005909 Thu Aug 3 18:18:02 1989 --- parse.y Thu Aug 3 17:43:33 1989 *************** *** 1419,1424 \h the hostname \# the command number of this command \! the history number of this command \<octal> character code in octal \\ a backslash */ --- 1419,1425 ----- \h the hostname \# the command number of this command \! the history number of this command + \$ a $, unless you are root, then a #. \<octal> character code in octal \\ a backslash */ *************** *** 1574,1579 case '\\': temp = savestring ("\\"); goto add_string; default: --- 1575,1584 ----- case '\\': temp = savestring ("\\"); + goto add_string; + + case '$': + temp = savestring (getuid () == 0 ? "#" : "$"); goto add_string; default: