[BusyBox] Sh/CmdEdit fixed.

Erik Andersen andersen at lineo.com
Wed Apr 4 18:46:28 UTC 2001


On Wed Apr 04, 2001 at 01:12:52PM -0400, Gennady Feldman wrote:
> Hello Everybody.
> 
> 	I am attaching patches which handle/fix the following issues (for
> me anyway):
> 1. when typing 'export' in lash busybox crashes.

thanks!


> Index: sh.c
> ===================================================================
> RCS file: /var/cvs/busybox/sh.c,v
> retrieving revision 1.117
> diff -u -r1.117 sh.c
> --- sh.c	2001/03/29 22:48:33	1.117
> +++ sh.c	2001/04/04 16:57:45
> @@ -811,7 +813,8 @@
>  #else
>  	PS1 = getenv("PS1");
>  	if(PS1==0) {
> -		PS1 = "\\w \\$ ";
> +		//PS1 = "\\w \\$ ";
> +		PS1 = "[\\u@\\h \\W]\\$ ";
>  	}
>  	PS2 = getenv("PS2");
>  	if(PS2==0) 

I'm going to skip this part.  The reason is that many embedded boxes
do not have networkig, so defaulting to showing the hostname, which
may not even be set up, is a bad idea.  Also, it is easy enough to
install an /etc/profile which sets PS1 to whatever you want it to be.


> Index: sh.c
> ===================================================================
> RCS file: /var/cvs/busybox/sh.c,v
> retrieving revision 1.117
> diff -u -r1.117 sh.c
> --- sh.c	2001/03/29 22:48:33	1.117
> +++ sh.c	2001/04/04 16:57:45
> @@ -426,7 +426,8 @@
>  		for (e = environ; *e; e++) {
>  			printf( "%s\n", *e);
>  		}
> -	}
> +		return 0;
> +	} else {

Good catch.

> Index: cmdedit.c
> ===================================================================
> RCS file: /var/cvs/busybox/cmdedit.c,v
> retrieving revision 1.47
> diff -u -r1.47 cmdedit.c
> --- cmdedit.c	2001/03/19 23:49:41	1.47
> +++ cmdedit.c	2001/04/04 16:58:13
> @@ -441,6 +441,21 @@
>  				add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf);
>  				continue;
>  #endif	
> +			case 'W':
> +				if (pwd_buf[0] == 0) {
> +					int l;
> +					char *z;
> +					
> +					getcwd(pwd_buf, PATH_MAX);
> +					l = strlen(pwd_buf);
> +					z = strrchr(pwd_buf,'/');
> +					if ( (z != NULL) && (z != pwd_buf) ) {
> +						z++;
> +						strcpy(pwd_buf,z);
> +					}
> +				}
> +				add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf);
> +				continue;
>  			case '!':
>  				snprintf(buf, sizeof(buf), "%d", num_ok_lines);
>  				add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, buf);

I don't have any real problem with this addition.  The more I think about it
though the more I realize that parse_prompt really should be in libbb

 -Erik

--
Erik B. Andersen   email:  andersen at lineo.com
--This message was written using 73% post-consumer electrons--





More information about the busybox mailing list