mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-23 17:01:05 +02:00
make read -[kq] always print the prompt, if any; after all they make sure they have a terminal anyway (10727)
This commit is contained in:
parent
ba1d606cb2
commit
f5b6feedca
2 changed files with 18 additions and 6 deletions
|
@ -1,5 +1,8 @@
|
||||||
2000-04-13 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
|
2000-04-13 Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
|
||||||
|
|
||||||
|
* 10727: Src/builtin.c: make read -[kq] always print the prompt,
|
||||||
|
if any; after all they make sure they have a terminal anyway
|
||||||
|
|
||||||
* 10726: Src/hashtable.c: fix field name for HAVE_NIS_PLUS
|
* 10726: Src/hashtable.c: fix field name for HAVE_NIS_PLUS
|
||||||
|
|
||||||
* 10725: Src/Zle/compcore.c, Src/Zle/compctl.c,
|
* 10725: Src/Zle/compcore.c, Src/Zle/compctl.c,
|
||||||
|
|
|
@ -3356,11 +3356,12 @@ int
|
||||||
bin_read(char *name, char **args, char *ops, int func)
|
bin_read(char *name, char **args, char *ops, int func)
|
||||||
{
|
{
|
||||||
char *reply, *readpmpt;
|
char *reply, *readpmpt;
|
||||||
int bsiz, c = 0, gotnl = 0, al = 0, first, nchars = 1, bslash;
|
int bsiz, c = 0, gotnl = 0, al = 0, first, nchars = 1, bslash, keys = 0;
|
||||||
int haso = 0; /* true if /dev/tty has been opened specially */
|
int haso = 0; /* true if /dev/tty has been opened specially */
|
||||||
int isem = !strcmp(term, "emacs"), izle = zleactive && getkeyptr;
|
int isem = !strcmp(term, "emacs"), izle = zleactive && getkeyptr;
|
||||||
char *buf, *bptr, *firstarg, *zbuforig;
|
char *buf, *bptr, *firstarg, *zbuforig;
|
||||||
LinkList readll = newlinklist();
|
LinkList readll = newlinklist();
|
||||||
|
FILE *oshout = NULL;
|
||||||
|
|
||||||
if ((ops['k'] || ops['b']) && *args && idigit(**args)) {
|
if ((ops['k'] || ops['b']) && *args && idigit(**args)) {
|
||||||
if (!(nchars = atoi(*args)))
|
if (!(nchars = atoi(*args)))
|
||||||
|
@ -3385,8 +3386,11 @@ bin_read(char *name, char **args, char *ops, int func)
|
||||||
if (!zleactive) {
|
if (!zleactive) {
|
||||||
if (SHTTY == -1) {
|
if (SHTTY == -1) {
|
||||||
/* need to open /dev/tty specially */
|
/* need to open /dev/tty specially */
|
||||||
SHTTY = open("/dev/tty", O_RDWR|O_NOCTTY);
|
if ((SHTTY = open("/dev/tty", O_RDWR|O_NOCTTY)) != -1) {
|
||||||
haso = 1;
|
haso = 1;
|
||||||
|
oshout = shout;
|
||||||
|
init_shout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* We should have a SHTTY opened by now. */
|
/* We should have a SHTTY opened by now. */
|
||||||
if (SHTTY == -1) {
|
if (SHTTY == -1) {
|
||||||
|
@ -3403,6 +3407,7 @@ bin_read(char *name, char **args, char *ops, int func)
|
||||||
setcbreak();
|
setcbreak();
|
||||||
readfd = SHTTY;
|
readfd = SHTTY;
|
||||||
}
|
}
|
||||||
|
keys = 1;
|
||||||
} else if (ops['u'] && !ops['p']) {
|
} else if (ops['u'] && !ops['p']) {
|
||||||
/* -u means take input from the specified file descriptor. *
|
/* -u means take input from the specified file descriptor. *
|
||||||
* -up means take input from the coprocess. */
|
* -up means take input from the coprocess. */
|
||||||
|
@ -3419,9 +3424,9 @@ bin_read(char *name, char **args, char *ops, int func)
|
||||||
for (readpmpt = firstarg;
|
for (readpmpt = firstarg;
|
||||||
*readpmpt && *readpmpt != '?'; readpmpt++);
|
*readpmpt && *readpmpt != '?'; readpmpt++);
|
||||||
if (*readpmpt++) {
|
if (*readpmpt++) {
|
||||||
if (isatty(0)) {
|
if (keys || isatty(0)) {
|
||||||
zputs(readpmpt, stderr);
|
zputs(readpmpt, (haso ? shout : stderr));
|
||||||
fflush(stderr);
|
fflush(haso ? shout : stderr);
|
||||||
}
|
}
|
||||||
readpmpt[-1] = '\0';
|
readpmpt[-1] = '\0';
|
||||||
}
|
}
|
||||||
|
@ -3462,6 +3467,8 @@ bin_read(char *name, char **args, char *ops, int func)
|
||||||
settyinfo(&shttyinfo);
|
settyinfo(&shttyinfo);
|
||||||
if (haso) {
|
if (haso) {
|
||||||
close(SHTTY);
|
close(SHTTY);
|
||||||
|
fclose(shout);
|
||||||
|
shout = oshout;
|
||||||
SHTTY = -1;
|
SHTTY = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3493,6 +3500,8 @@ bin_read(char *name, char **args, char *ops, int func)
|
||||||
/* dispose of result appropriately, etc. */
|
/* dispose of result appropriately, etc. */
|
||||||
if (haso) {
|
if (haso) {
|
||||||
close(SHTTY);
|
close(SHTTY);
|
||||||
|
fclose(shout);
|
||||||
|
shout = oshout;
|
||||||
SHTTY = -1;
|
SHTTY = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue