#include <sys/stat.h>
#endif
-#ifdef BB_FEATURE_USERNAME_COMPLETION
-#include <pwd.h>
-#endif
+#include "pwd_grp/pwd.h"
+
static const int MAX_HISTORY = 15; /* Maximum length of the linked list for the command line history */
struct winsize win = { 0, 0, 0, 0 };
static __sighandler_t previous_SIGWINCH_handler; /* for reset */
- /* emulate || signal call */
+ /* emulate signal call if not called as a sig handler */
if(nsig == -SIGWINCH || nsig == SIGWINCH) {
ioctl(0, TIOCGWINSZ, &win);
if (win.ws_col > 0) {
cmdedit_setwidth( win.ws_col, nsig == SIGWINCH );
- }
+ } else {
+ /* Default to 79 if their console doesn't want to share */
+ cmdedit_setwidth( 79, nsig == SIGWINCH );
+ }
}
- /* Unix not all standart in recall signal */
+
+ /* Unix not all standart in recall signal */
- if(nsig == -SIGWINCH) /* save previous handler */
+ if(nsig == -SIGWINCH) /* save previous handler */
previous_SIGWINCH_handler = signal(SIGWINCH, win_changed);
else if(nsig == SIGWINCH) /* signaled called handler */
- signal(SIGWINCH, win_changed); /* set for next call */
+ signal(SIGWINCH, win_changed); /* set for next call */
else /* set previous handler */
signal(SIGWINCH, previous_SIGWINCH_handler); /* reset */
}
input_backward();
}
} else {
- error_msg("\n*** Error: minimum screen width is %d\n", cmdedit_termw);
+ error_msg("\n*** Error: minimum screen width is %d", cmdedit_termw);
}
}
extern void cmdedit_init(void)
{
if((handlers_sets & SET_WCHG_HANDLERS)==0) {
- /* emulate usage handler to set handler and call yours work */
+ /* pretend we received a signal in order to set term size and sig handling */
win_changed(-SIGWINCH);
handlers_sets |= SET_WCHG_HANDLERS;
}