onetrueawk / awk

One true awk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build: bison compat: colour mess

sdaoden opened this issue · comments

Hello.

For literally years the build system of nawk (and only that) causes problems when building on glibc/Linux (CRUX Linux that is):

`=======> Building '/usr/ports/built/nawk#20240422-bsd-1.pkg.tar.zst'.
bsdtar -p -o -C /tmp/.pkgmk/src -xf /x/balls/awk-20240422-bsd.tar.gz

  • build
  • cd awk-31bb33a32f710d342fa4f6a0509bea46722d0df5
  • make
    bison -d awkgram.y
    bison -d awkgram.y
    awkgram.y: awkgram.y: warning: 62 shift/reduce conflicts [=5warning:994dc[73090;04691m6eff 62 shift/reduce conflicts [e11d6ef]080;0i0d0=0509;9h4tdtcp7s7:0/0/0w6w1w6.egfnfue.1o1rdg7/7s5o0f0t0w
    0a0r0e0/0b;ihstotnp/sm:a/n/uwawlw/.hgtnmul._onrogd/es/oDfitawganroes/tbiicsso.nh/tmmaln#uWaclo/nhftlmilc_tnso-dser/
    \i-Wconflicts-sra[n3o9s;t4i9cmsh8t;m;lWco]n
    flicts-sr-Wconflicts-srwkgram.y9: mwarning:\9
    m 87 reduce/reduce conflicts [cwarning:7[03090;64196mef f87 reduce/reduce conflictse [11d6]f80;0i0d0=05090914;dhct7t7p0s0:0/6/1w6wewf.fgen1u1.do7r7g5/0s0o0f0t0w0a0r1e;/hbtitsposn://m/awnwuwa.
    lg/nhut.molr_gn/osdoef/tDwiaargen/obsitsiocns/.mhatnmula#lW/chotnmfll_incotdse-/rDri\g-Wconflicts-rrn[s3t9i;c4s9.mh]m8l;#;W
    \on]f
    lawkgram.yi: cts-rr-Wconflicts-rr3note:9[4399m;]98m;; erun with option '-Wcounterexamples' to generate conflict counterexamples
    ]
    awkgram.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o awkgram.tab.o awkgram.tab.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o b.o b.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o main.o main.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o parse.o parse.c
    cc -g -Wall -pedantic -Wcast-qual -O2 maketab.c -o maketab
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o tran.o tran.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o lib.o lib.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o run.o run.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o lex.o lex.c
    ./maketab awkgram.tab.h >proctab.c
    cc -g -Wall -pedantic -Wcast-qual -O2 -c -o proctab.o proctab.c
    cc -g -Wall -pedantic -Wcast-qual -O2 awkgram.tab.o b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -lm
  • install -D a.out /tmp/.pkgmk/pkg/usr/bin/nawk
  • install -D -m 0644 awk.1 /tmp/.pkgmk/pkg/usr/share/man/man1/nawk.1
    =======> Build result:
    drwxr-xr-x 0 root root 0 Apr 25 20:31 usr/
    drwxr-xr-x 0 root root 0 Apr 25 20:31 usr/share/
    drwxr-xr-x 0 root root 0 Apr 25 20:31 usr/bin/
    -rwxr-xr-x 0 root root 159928 Apr 25 20:31 usr/bin/nawk
    drwxr-xr-x 0 root root 0 Apr 25 20:31 usr/share/man/
    drwxr-xr-x 0 root root 0 Apr 25 20:31 usr/share/man/man1/
    -rw-r--r-- 0 root root 5606 Apr 25 20:31 usr/share/man/man1/nawk.1.gz
    =======> Building '/usr/ports/built/nawk#20240422-bsd-1.pkg.tar.zst' succeeded.
    =======> Footprint updated.`

As i personally never used yacc/bison and hate automatic code generation in general i have no idea and never looked, but over and over see this; so i though "report it", finally.
Thank you!!

(Ie (no idea of github and those rich text things here) i see purple and turquoise beside that garbage.)

If you edit the makefile to add --color=no to the end of the YACC definition does the garbage go away?

Hello Todd Miller! Yes, that does it.

I must add it happens in a package system that is unshare(1)d (Linux) and such. (Very recursive shells, eval's and such. Funnily i cannot reproduce it from inside the container manually, but can if just run the package system as such. $TERM should be tmux-colour...)

Ok i am looking; what happens is that if i edit the package builder to say "</dev/tty build" it is ok, but if i use the "fakeroot" program to run this, it again fails.
Note that running "ls -latr --color=always" in the same circumstances gives good results.
Seems to be a bison problem, too.
So it seems to me the --tty=auto detection of bison somehow causes

Bison uses GNU libtextstyle which should be using the value of TERM and the associated termcap/terminfo database to determine whether colors are supported. Perhaps there are bugs in it. Anyway, this doesn't really seem like an awk issue.

Yes. (Funnily isatty goes for STDERR in bison/src/complain.c).
I will patch the nawk Makefile to work around this though.

@sdaoden Please send in a bug report to the bison maintainers. (Parenthetically, checking stderr for isatty() makes sense, since stdout could be going down a pipeline or into a file.)

@arnoldrobbins .. just to remark that STDERR seems to be the right thing given that POSIX defines for the sh(1)ll:

115119 Standard input and standard error are the files that determine whether a shell is interactive 115120 when −i is not specified. For example: 115121 sh > file 115122 and: 115123 sh 2> file 115124 create interactive and non-interactive shells, respectively. Although both accept terminal input, 115125 the results of error conditions are different

(sorry for that formatting! i had used the "code" thing from the toolbar?!)