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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script unparsing is a bit too verbose #240

Closed
angelhof opened this issue Apr 30, 2021 · 2 comments
Closed

Script unparsing is a bit too verbose #240

angelhof opened this issue Apr 30, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@angelhof
Copy link
Member

Currently (after the recent changes to improve posix compliance) there are too many braces in the output script.

For example, here is the mkfifo function for evaluation/intro/demo-spell.sh. 馃あ

mkfifo_pash_fifos() {
{ mkfifo "/tmp/pash_62bv3tca/#fifo2" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo4" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo6" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo8" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo10" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo14" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo15" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo16" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo17" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo18" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo19" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo20" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo21" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo22" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo23" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo24" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo25" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo26" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo27" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo28" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo29" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo30" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo31" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo32" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo33" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo34" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo35" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo36" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo37" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo38" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo39" ; }
 { { mkfifo "/tmp/pash_62bv3tca/#fifo40" ; }
 { mkfifo "/tmp/pash_62bv3tca/#fifo41" ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; } ; }
}

Once we have a posix compliance infrastructure setup, we can play around with different ways to print less verbose code without breaking correctness.

@mgree do you have any thoughts on the above? For example, would it be sound to not add braces around single commands?

@angelhof angelhof added the enhancement New feature or request label Apr 30, 2021
@mgree
Copy link
Collaborator

mgree commented May 9, 2021

Yes, completely sound to omit them for a single command.

There are times you really, really want to do it anyway, though: notably, at function definitions. (POSIX says f() echo hi is a perfectly good definition of a function f, but e.g., bash rejects it.)

@mgree
Copy link
Collaborator

mgree commented May 9, 2021

I feel like the real thing we want here is a properly tested, properly written pretty printer. The tests on the OCaml AST from libdash are obviously insufficient, and the printer itself is wrong in numerous places.

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

No branches or pull requests

2 participants