duckscript icon indicating copy to clipboard operation
duckscript copied to clipboard

Newline Escapes

Open enderger opened this issue 3 years ago • 3 comments
trafficstars

Feature Description

Currently, DuckScript appears to lack any means to split up long lines. A simple \ before a newline probably is a good yet simple solution to the problem.

Describe The Solution You'd Like

At the end of lines, including a \ character should tell the parser to ignore the newline and continue parsing the command on the previous line.

Code Sample

exec --fail-on-error nix build ".#docker-image" \
  --arg foo true \
  --arg bar ${var} \
  --arg baz "Lorem ipsum"

enderger avatar Jul 07 '22 23:07 enderger

@enderger thanks for the suggestion. i made duckscript stupid simple on purpose, but i get your point that this might hurt readability for long lines. let me think of something here....

sagiegurari avatar Jul 11 '22 18:07 sagiegurari

We are aware that it is intentionally simple, and find that a strong quality. Looking into the source, it seems that there would need a modification to line splitting (the solution with the least code would be changing the delimiter, but that would require something like semicolons), perhaps using replace before splitting into lines (those followed by a space would be implicitly escaped).

enderger avatar Jul 11 '22 18:07 enderger

@enderger i'm not worried about parsing. The technical issue is actually the parsed line metadata (such as a command line) that has which file and line number it came from). for that i'm not going to support the right line, only define it as the first line. i think its good enough but not as amazing as i would hope. also since the next line would actually be not available, gotos would have to skip to next available line... this might happen already. need to check.

sagiegurari avatar Jul 12 '22 05:07 sagiegurari