View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000491 | tcsh | General | public | 2023-12-01 21:46 | 2023-12-02 00:33 |
Reporter | MProG10 | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | new | Resolution | open | ||
Summary | 0000491: $?< for substituting whether there is available data from stdin. | ||||
Description | $?< substitutes 1 if there is available data from stdin, 0 if there is not. | ||||
Additional Information | https://github.com/tcsh-org/tcsh/pull/90 | ||||
Tags | No tags attached. | ||||
|
sh.err.c.diff (581 bytes)
--- a/sh.err.c +++ b/sh.err.c @@ -294,7 +294,7 @@ errinit(void) elst[ERR_NOHOME] = CSAVS(1, 78, "No $home variable set"); elst[ERR_HISTUS] = CSAVS(1, 79, "Usage: history [-%s] [# number of events]"); - elst[ERR_SPDOLLT] = CSAVS(1, 80, "$, ! or < not allowed with $# or $?"); + elst[ERR_SPDOLLT] = CSAVS(1, 80, "$ or ! not allowed with $%%, $# or $?"); elst[ERR_NEWLINE] = CSAVS(1, 81, "Newline in variable name"); elst[ERR_SPSTAR] = CSAVS(1, 82, "* not allowed with $# or $?"); elst[ERR_DIGIT] = CSAVS(1, 83, "$?<digit> or $#<digit> not allowed"); sh.dol.c.diff (677 bytes)
--- a/sh.dol.c +++ b/sh.dol.c @@ -29,6 +29,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#include <poll.h> + #include "sh.h" #include "ed.h" #include "tw.h" @@ -450,8 +452,21 @@ Dgetdol(void) case '<'|QUOTE: { static struct Strbuf wbuf; /* = Strbuf_INIT; */ - if (bitset) - stderror(ERR_NOTALLOWED, "$?<"); + if (bitset) { + struct pollfd pfd = { + OLDSTD, + POLLIN + }; + + if (poll(&pfd, 1, 0) > 0 && + pfd.revents & POLLIN) + dolp = STR1; + else + dolp = STR0; + cleanup_until(name); + + goto eatbrac; + } if (dimen) stderror(ERR_NOTALLOWED, "$#<"); if (length) sh.lex.c.diff (250 bytes)
--- a/sh.lex.c +++ b/sh.lex.c @@ -536,11 +536,11 @@ getdol(void) Strbuf_append1(&name, c); switch (c) { - case '<': case '$': case '!': if (special) seterror(ERR_SPDOLLT); + case '<': goto end; case '\n': |