pash
pash copied to clipboard
Script unparsing is a bit too verbose
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?
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.)
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.