View Issue Details

IDProjectCategoryView StatusLast Update
0000491tcshGeneralpublic2023-12-02 00:33
ReporterMProG10 Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0000491: $?< 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 Informationhttps://github.com/tcsh-org/tcsh/pull/90
TagsNo tags attached.

Activities

MProG10

2023-12-02 00:33

reporter   ~0003980

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':
sh.lex.c.diff (250 bytes)   
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.dol.c.diff (677 bytes)   
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.err.c.diff (581 bytes)   

Issue History

Date Modified Username Field Change
2023-12-01 21:46 MProG10 New Issue
2023-12-02 00:33 MProG10 Note Added: 0003980
2023-12-02 00:33 MProG10 File Added: sh.err.c.diff
2023-12-02 00:33 MProG10 File Added: sh.dol.c.diff
2023-12-02 00:33 MProG10 File Added: sh.lex.c.diff