Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENVIRON variable support? #107

Open
linux-china opened this issue Jan 2, 2024 · 1 comment
Open

ENVIRON variable support? #107

linux-china opened this issue Jan 2, 2024 · 1 comment

Comments

@linux-china
Copy link

ENVIRON, array of environment variables, and support by awk and gawk.

@pmarreck
Copy link

Just ran into this issue over here:

pmarreck 🟢 21ms
20240918170311 ~ bash> SIXEL_CAPABLE=false frawk 'BEGIN{OFS=" "; a="fortune inthebeginning warhammer_quote bashorg_quote chuck mandelbrot asciidragon just_one_taoup"; split(a,b); if(ENVIRON["SIXEL_CAPABLE"]=="true") {print a} else {for(i in b) if(b[i]!="inthebeginning") printf "%s%s", b[i], (i<length(b)?OFS:ORS);};}'
fortune inthebeginning warhammer_quote bashorg_quote chuck mandelbrot asciidragon just_one_taoup

pmarreck 🟢 34ms
20240918170403 ~ bash> SIXEL_CAPABLE=false awk 'BEGIN{OFS=" "; a="fortune inthebeginning warhammer_quote bashorg_quote chuck mandelbrot asciidragon just_one_taoup"; split(a,b); if(ENVIRON["SIXEL_CAPABLE"]=="true") {print a} else {for(i in b) if(b[i]!="inthebeginning") printf "%s%s", b[i], (i<length(b)?OFS:ORS);};}'
fortune warhammer_quote bashorg_quote chuck mandelbrot asciidragon just_one_taoup

Awk (and not frawk) changes its behavior based on the environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants