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

sassc hangs when called with no args #177

Merged
merged 1 commit into from
Jul 25, 2016
Merged

sassc hangs when called with no args #177

merged 1 commit into from
Jul 25, 2016

Conversation

luizberti
Copy link
Contributor

This pull just checks if argc == 1 and if so, prints the usage guide and returns 0 just like calling it with -h would.

@xzyfer
Copy link
Contributor

xzyfer commented Jul 25, 2016

Thanks @LuizFB

@xzyfer xzyfer merged commit 0730454 into sass:master Jul 25, 2016
@saper
Copy link
Member

saper commented Jul 25, 2016

Well, it does not hang. It just waits for Sass input from the standard input, I've been using it pretty often.
Just press Ctrl-D/Ctrl-Z/whatever EOF you have on your platform.

This change now breaks this.

@luizberti
Copy link
Contributor Author

luizberti commented Jul 25, 2016

@saper Well it's not really about "just press Ctrl-D", that's not the behaviour most people expect when using command line programs.

Usual behaviour is:

  • Empty call prints help text
  • Pass - as an arg so it reads from STDIN

That's what virtually what every program does. No reason to not just have another PR that adds "- as STDIN" as a feature, but as it stands, that just feels like funky behaviour, especially since it just hangs indefinitely when theres no input.

There could, alternatively, be a check to verify if there is actually any piped input to be received from STDIN, and if not, prints the help text, else reads from it. That would probably the easiest fix, although the "right" thing to do would be to conform to default behaviour of just using -.

@saper
Copy link
Member

saper commented Jul 25, 2016

It depends on the tradition one subscribes to. If you are used to the Unix-like command line, no arguments usually mean standard input (like a filter) scenario.

@saper
Copy link
Member

saper commented Jul 25, 2016

The original bug report was about "hanging", not about discussing of the expected command line behaviour.

Checking for piped (typed, maybe?) output is way too complex and almost certainly incorrect.

saper added a commit to saper/sassc that referenced this pull request Jul 25, 2016
@luizberti
Copy link
Contributor Author

luizberti commented Jul 25, 2016

Nothing complex about it, it only takes a call to isatty().

We could debate this forever, but I fear that would be counterproductive. Since it was never my intention to have it stop complying to a use case, and there is an obvious (and easy) fix that tends to everyone's demands, I propose just checking if STDIN is a pipe or not, and acting accordingly, rather than reverting the pull.

That way it will go back to working as you expected, and when there is no piped input to be had it will not dumbly sit there idling. Sounds reasonable?

@saper
Copy link
Member

saper commented Jul 25, 2016

isatty() has its problems. It is a POSIX interface and does not exist on Windows (unless worked around). It breaks my way (possibly could be considered as unusual) to paste the input straight into the the terminal running sassc. It also breaks some situations where pseudoterminal is being provided but the processing is not fully interactive (things like script(1) etc.).

I really think we should refrain from this "simple" change (#177). I'll leave it up to @xzyfer to decide.

@luizberti
Copy link
Contributor Author

It does exist in Windows under io.h, It's only a matter adding that to the ifdefs.

As for the quite unusual use cases of your clipboard usage and script(1), I fall back to my argument about being able to explicitly list STDIN as an argument using -. It's fairly standard UNIX convention, the most handy examples would be tar and nc but I could cite others. And in any case you could still always pbpaste | sassc or your system's equivalent if you wanted to.

@xzyfer
Copy link
Contributor

xzyfer commented Jul 26, 2016

I agree with @LuizFB that the existing behaviour is surprising. I would prefer we detect stdin or an --stdin flag. IMHO the current "hanging" behaviour is the worse case.

However given that it was hanging waiting for stdin this is a significant breaking a change, so I will revert it.

We should address a suitable implementation that does not hang like this for 3.4.

xzyfer pushed a commit that referenced this pull request Jul 26, 2016
@luizberti
Copy link
Contributor Author

luizberti commented Jul 26, 2016

@xzyfer Any opinion on using isatty() with unistd.h and io.h on the ifdefs?

That would be the quickest and easiest way to fix it IMO, and then later is just a matter of adding the stdin explicit flag whenever you feel like. I could make another PR if you want.

@xzyfer
Copy link
Contributor

xzyfer commented Jul 27, 2016

@LuizFB in theory it sounds idea but honestly it's out of my area of knowledge.

I always give @saper the benefit of the doubt. I expect the concerns he's raised about some edge cases will need to be addressed. However for now there's a way to implement what you suggest that'll work for the vast majority of people I'm 👍 . We can address the edges case as people file issues.

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

Successfully merging this pull request may close these issues.

4 participants