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

eask analyze output is sent to stderr #276

Open
joshbax189 opened this issue Nov 5, 2024 · 6 comments
Open

eask analyze output is sent to stderr #276

joshbax189 opened this issue Nov 5, 2024 · 6 comments

Comments

@joshbax189
Copy link
Contributor

joshbax189 commented Nov 5, 2024

This means eask analyze does not play nicely in shell scripts.

Specifically, I want to do

eask analyze | grep "Warning"

Some commands will separate output and error per #123

> eask files
Unmatched dependency 'emacs'; add (emacs "VERSION") to package-file or consider removing it
# ...etc
/some/file/here

(Total of 1 item listed)

vs

> eask files 2>/dev/null
/some/file/here
@joshbax189
Copy link
Contributor Author

joshbax189 commented Nov 5, 2024

This is actually a weird emacs thing:

> emacs --batch --eval "(message \"hi\")" 1>/dev/null
hi
> emacs --batch --eval "(message \"hi\")" 2>/dev/null
# nothing

From the man page

--batch Edit in batch mode. The editor will send messages to
stderr. You must use -l and -f options to specify files
to execute and functions to call.

Same for the --script flag, it seems.

So is eask a wrapper for emacs --script or is it "npm for emacs"? 😃

@jcs090218
Copy link
Member

Hmmm… the same issue should have been solved a long while ago. See #124.

So is eask a wrapper for emacs --script or is it "npm for emacs"? 😃

Eask is the wrapper for emacs —script. Eask is not trying to hide any bugs from Emacs; therefore, the nodejs layer should forward all stdin, stdout, and stderr.

@joshbax189
Copy link
Contributor Author

Ah sorry, I didn't search hard enough, now I found #123
Now I see that some commands do output to stdout, just not the ones I chose to test with!

My main problem was eask analyze only outputs to stderror or nothing. This was confusing, as IMO the warnings are the expected output. I'll change the issue to specifically that.

PS: a side-effect of the above observation about emacs' --script option is that eask messages can't be separated from program messages when running eask eval, e.g.

> eask eval '(message "hello")' 
Warning (package): Package lacks a terminating comment
Warning (emacs): Unmatched dependency 'emacs'; add (emacs "VERSION") to package-file or consider removing it
Updating environment variables... done ✓
Exporting environment variables... done ✓
hello

But then, if I want to hide the diagnostic messages:

> eask eval '(message "hello")' 2>/dev/null
# no output

All of the message output of eask eval is gone too.

@joshbax189 joshbax189 changed the title All normal output is sent to stderr eask analyze output is sent to stderr Nov 5, 2024
@jcs090218
Copy link
Member

My main problem was eask analyze only outputs to stderror or nothing. This was confusing, as IMO the warnings are the expected output. I'll change the issue to specifically that.

Yeah, the analyze command only output to the stderr stream. See

(eask-msg content))

(mapc #'eask-msg (reverse eask-analyze--log)))

We can change to standard output instead. :)

All of the message output of eask eval is gone too.

Hmm... the eval command did forward all standard streams. 🤔

let proc = child_process.spawn(UTIL.cli_args(cmd), { stdio: 'inherit', shell: true });

@joshbax189
Copy link
Contributor Author

Thanks for checking!

Hmm... the eval command did forward all standard streams

Sorry this was a little off-topic from the main issue. My point was that both emacs and eask write to standard error, so when using the eask eval command there's no easy way to separate eask output from emacs output. E.g. if I want eask eval to exactly match emacs --script how would I do it?

I wonder if the --verbose option should hide eask messages, e.g. eask eval [form] -v 0 forbids Eask from printing any (own) messages.

@jcs090218
Copy link
Member

Sorry, this was a little off-topic regarding the main issue.

No worries! I might have misunderstood your question! 😅

My point was that both emacs and eask write to standard error, so when using the eask eval command there's no easy way to separate eask output from emacs output. E.g. if I want eask eval to exactly match emacs --script how would I do it?

Do you mean the Node.js layer and Emacs outputs? Right now, there is no way to separate these outputs. We will have to change the command behavior. 🤔

I wonder if the --verbose option should hide eask messages, e.g. eask eval [form] -v 0 forbids Eask from printing any (own) messages.

Eask is hybrid (Node.js + Elisp), so it has to print something, or else it would have no outputs. 🤔

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