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

heredoc is lost when parsing into syntax::List #229

Open
kpcyrd opened this issue Jan 5, 2023 · 1 comment
Open

heredoc is lost when parsing into syntax::List #229

kpcyrd opened this issue Jan 5, 2023 · 1 comment

Comments

@kpcyrd
Copy link
Contributor

kpcyrd commented Jan 5, 2023

hi!

I have a program like this:

use yash_syntax::syntax;

fn main() {
    let script = r#"
echo 123
cat 1>&2 <<EOF
this is lost
EOF
echo 'but
multiple
lines
work'
"#; 
    let parsed: syntax::List = script
        .parse().unwrap();
    println!("{}", parsed);
}

and executing it gives me this output:

echo 123; cat 1>&2 <<EOF; echo 'but
multiple
lines
work'

the heredoc is lost and the shell code is semi-invalid, it still executes but gives a warning/error:

sh: line 4: warning: here-document at line 4 delimited by end-of-file (wanted `EOF')
123
but
multiple
lines
work

Is there a way to preserve the heredoc?

Thank you for making this crate!

@magicant
Copy link
Owner

magicant commented Jan 6, 2023

Actually the here-doc is lost not when parsing, but when printing.
Unfortunately I have to say the Display implementation of the yash_syntax crate does not yet support printing here-docs. I intend to implement it, but it won't be very soon.

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