Index: scripts/individual =================================================================== --- scripts/individual (revision 16161) +++ scripts/individual (working copy) @@ -126,4 +126,4 @@ else fi -strip build/* +#strip build/* Index: console-tools/Makefile.in =================================================================== --- console-tools/Makefile.in (revision 16161) +++ console-tools/Makefile.in (working copy) @@ -20,6 +20,7 @@ CONSOLETOOLS-$(CONFIG_LOADFONT) += loadf CONSOLETOOLS-$(CONFIG_LOADKMAP) += loadkmap.o CONSOLETOOLS-$(CONFIG_OPENVT) += openvt.o CONSOLETOOLS-$(CONFIG_RESET) += reset.o +CONSOLETOOLS-$(CONFIG_RESIZE) += resize.o CONSOLETOOLS-$(CONFIG_SETKEYCODES) += setkeycodes.o CONSOLETOOLS-$(CONFIG_SETLOGCONS) += setlogcons.o Index: console-tools/resize.c =================================================================== --- console-tools/resize.c (revision 0) +++ console-tools/resize.c (revision 0) @@ -0,0 +1,41 @@ +/* vi: set sw=4 ts=4: */ +/* + * resize - set terminal width and height. + * + * Copyright 2006 Bernhard Fischer + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + */ +/* no options, no getopt */ +#include "busybox.h" + +#define RESIZE_TIOS_TIMEOUT 100 /* in deciseconds */ +int resize_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv) { + /* save_cursor_pos 7 + * scroll_whole_screen [r + * put_cursor_waaaay_off [$x;$yH + * get_cursor_pos [6n + * restore_cursor_pos 8 + */ + struct winsize w = {0,0,0,0}; + int ret; + struct termios old, new; + tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */ + new = old; + new.c_cflag |= (CLOCAL | CREAD); + new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); +#if defined(RESIZE_TIOS_TIMEOUT) && (RESIZE_TIOS_TIMEOUT > 0) + new.c_cc[VMIN] = 0; + new.c_cc[VTIME] = RESIZE_TIOS_TIMEOUT; +#endif + tcsetattr(STDOUT_FILENO, TCSANOW, &new); + printf("\0337\033[r\033[999;999H\033[6n"); + scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col); + ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w); + printf("\0338"); + tcsetattr(STDOUT_FILENO, TCSANOW, &old); + if (00 && argc > 1) + printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;", + w.ws_col, w.ws_row); + return ret; +} Index: console-tools/Config.in =================================================================== --- console-tools/Config.in (revision 16161) +++ console-tools/Config.in (working copy) @@ -58,6 +58,13 @@ config CONFIG_RESET This program is used to reset the terminal screen, if it gets messed up. +config CONFIG_RESIZE + bool "resize" + default n + help + This program is used to (re)set the width and height of your current + terminal. + config CONFIG_SETCONSOLE bool "setconsole" default n Index: shell/bbsh.c =================================================================== --- shell/bbsh.c (revision 16161) +++ shell/bbsh.c (working copy) @@ -60,7 +60,7 @@ struct command { // A collection of processes piped into/waiting on each other. struct pipeline { struct pipeline *next; - int job_id; + //unsigned int job_id; struct command *cmd; char *cmdline; int cmdlinelen; @@ -119,7 +119,7 @@ static char *parse_pipeline(char *cmdlin char *end; // Skip leading whitespace and detect end of line. - while (isspace(*start)) start++; + start = skip_whitespace(start); if (!*start || *start=='#') { if (ENABLE_BBSH_JOBCTL) line->cmdlinelen = start-cmdline; return 0; @@ -154,22 +154,21 @@ static char *parse_pipeline(char *cmdlin static int run_pipeline(struct pipeline *line) { struct command *cmd = line->cmd; + char *argv0 = cmd->argv[0]; if (!cmd || !cmd->argc) return 0; // Handle local commands. This is totally fake and plastic. - if (cmd->argc==2 && !strcmp(cmd->argv[0],"cd")) + if (cmd->argc==2 && !strcmp(argv0,"cd")) chdir(cmd->argv[1]); - else if(!strcmp(cmd->argv[0],"exit")) + else if(!strcmp(argv0,"exit")) exit(cmd->argc>1 ? atoi(cmd->argv[1]) : 0); else { - int status; pid_t pid=fork(); if(!pid) { - run_applet_by_name(cmd->argv[0],cmd->argc,cmd->argv); - execvp(cmd->argv[0],cmd->argv); - printf("No %s",cmd->argv[0]); - exit(1); - } else waitpid(pid, &status, 0); + run_applet_by_name(argv0,cmd->argc,cmd->argv); + execvp(argv0,cmd->argv); + bb_perror_msg_and_die("%s",argv0); + } else waitpid(pid, NULL, 0); } return 0; Index: include/libbb.h =================================================================== --- include/libbb.h (revision 16161) +++ include/libbb.h (working copy) @@ -231,8 +231,9 @@ extern void trim(char *s); extern char *skip_whitespace(const char *); #ifndef BUILD_INDIVIDUAL -extern struct BB_applet *find_applet_by_name(const char *name); -void run_applet_by_name(const char *name, int argc, char **argv); +extern struct BB_applet *find_applet_by_name(const char *name) + USE_FEATURE_SH_STANDALONE_SHELL(ATTRIBUTE_EXTERNALLY_VISIBLE); +extern void run_applet_by_name(const char *name, int argc, char **argv); #endif /* dmalloc will redefine these to it's own implementation. It is safe Index: include/usage.h =================================================================== --- include/usage.h (revision 16163) +++ include/usage.h (working copy) @@ -2455,6 +2455,11 @@ USE_FEATURE_MDEV_CONFIG( \ #define reset_full_usage \ "Resets the screen." +#define resize_trivial_usage \ + "" +#define resize_full_usage \ + "Resizes the screen." + #define rm_trivial_usage \ "[OPTION]... FILE..." #define rm_full_usage \ Index: include/applets.h =================================================================== --- include/applets.h (revision 16161) +++ include/applets.h (working copy) @@ -226,6 +226,7 @@ USE_REALPATH(APPLET(realpath, _BB_DIR_US USE_HALT(APPLET_ODDNAME(reboot, halt, _BB_DIR_SBIN, _BB_SUID_NEVER, reboot)) USE_RENICE(APPLET(renice, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_RESET(APPLET(reset, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) +USE_RESIZE(APPLET(resize, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) USE_RM(APPLET(rm, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_RMDIR(APPLET(rmdir, _BB_DIR_BIN, _BB_SUID_NEVER)) USE_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_NEVER))