3

NOTE: This question is not asking about using tag-warnings, nor is it specifically about templates - it is about calling shellcheck on shell scripts so that people don't have to waste time debugging issues that that tool could debug. The mention of templates is just one way of isolating the code so shellcheck can be run on it but the question is about calling a tool on provided code, and not about utilizing existing technology for this purpose.

The [bash] tag info on SO and Unix.SE:

both request that people run their code through http://shellcheck.net (or the equivalent command-line Unix tool also named shellcheck) before posting a question about it. Most questions we see, however, contain bugs that shellcheck would have caught (e.g see bash script error with variable set to awk command) so the code posted in the question either:

  1. Didn't need to be asked at all as shellcheck would have answered it, or
  2. Has its real problem obscured by many bugs that the OP could have cleared up by using shellcheck and thus making the real problem much easier to spot.

We also frequently see people posting questions with one of sample input, expected output, or code missing.

It'd be much easier to help people if we had a template for any type of Unix shell question at least which had sections for sample input, expected output, and code and which ran the code through shellcheck and forced the OP to have that result in zero errors (possibly with an override they could use if they just can't get there) before posting the question.

That would have no negatives for the users (other than the OP having to clean up their question before we see it rather than after) but would avoid many posters having their questions downvoted and/or closed for not providing the necessary info and not running shellcheck while greatly reducing:

  1. How many questions are posted,
  2. How many comments we have to post asking for input, output, and/or code and/or the OP to run shellcheck,
  3. How much time we waste identifying, explaining and fixing issues that shellcheck could have done,
  4. How much time we spend coming up with answers.

So - can we do that and, if so, how do we go about making it happen?

To be clear - I am not suggesting using a tag-warning (a popup when you use a tag stating the requirements for asking a question with that tag). Instead I'm requesting we get a template for Unix shell questions where a common tool, shellcheck, gets called to evaluate the code the OP provides in the code section of the template so the OP can remove most common bugs themselves before posting a question if a question is still required.

5
  • 2
    The tag wikis have way too little visibility for this to work. Nov 21, 2021 at 18:18
  • @P.Mort.-forgotClayShirky_q by "this" in your comment do you mean a) my suggestion/request or b) tag-warnings or c) posting my question here with the given tags in hopes of getting action taken, or d) something else?
    – Ed Morton
    Nov 21, 2021 at 18:20
  • 3
    Thank you for your edit Ed. It's clear now that rather than asking the user to do it themselves you want to enable a means to do it automatically; much like adding spellchecking or fbinfer.com for C, C++, and Java code, etc.
    – Rob
    Nov 21, 2021 at 20:24
  • 3
    It seems that one possible workflow would be as follows: 1) User types in their question. 2) User proofreads their question and decides on a great title; prompting a refresh of the Duplicate Suggestions on the right. 3) User adds the appropriate tags, including "bash". 4) Now a message appears informing them that a template has been appended to their question, and that they must cut and paste each portion of their question into the respective section of the template. 5) Next they push a button which runs the bash script portion through a Stack Exchange hosted version of shellcheck. ...
    – Rob
    Nov 21, 2021 at 21:09
  • So... now what? I asked this question, we still get questions asked every day that don't need to be asked if the users ran shellcheck on their code (e.g. stackoverflow.com/q/70260474/1745001), almost every Unix shell question could be significantly improved by doing so as they almost all contain some errors that shellcheck could detect, explain, and correct (e.g. stackoverflow.com/q/70260370/1745001) but nothing seems to have changed as a result of this question. Is there something else I need to do to request this feature?
    – Ed Morton
    Dec 7, 2021 at 13:39

1 Answer 1

6

I don't think that there's anything like templates currently available (though a generic template was tested on Stack Overflow). I can recommend another tool: tag warnings.

Imagine! Whenever someone puts the tag [bash] on their question draft, they see a warning explaining what they need to do before asking.

You can ask about enabling this for a tag on your child meta. See Warn people of the rules for [Single-Word-Requests] before posting as an example that I posted. Here's an outline of the steps involved:

  1. Ask a question on the child meta: Do we want a tag warning for this tag? What should the wording be?
  2. You may ask (flag) a moderator to tag it as to get more attention on it. Hopefully the community agrees with your idea and you decide on a wording.
  3. Have a moderator escalate it with , as documented here: What's the protocol for requesting a tag warning?

See Help the helpless with how-to-ask tag tips for where this feature was first announced. The exact appearance has changed a little but the idea's still the same.

Why will this make a difference when the tag description fails to? At least on U&L, people asking a question don't see any mention of ShellCheck: "Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead. For shell scripts with...". It's only the first ~180 characters of the tag description that are shown. And on Stack Overflow, where ShellCheck is visible in the description, there's no obvious way to click it to visit the site. (Finding the full tag description is something that even a number of high-rep users don't know how to do.)

Not everyone will follow the warning but some will. I see some people directly addressing the warning in their question so I know it's at least somewhat effective.

4
  • 1
    Thanks for the information. Obviously it's not what I was asking for in my question but it would be a bit better than what we have today as an a band-aid for now.
    – Ed Morton
    Nov 21, 2021 at 18:04
  • @EdMorton By the way, people on U&L don't see the instruction to use ShellCheck. See edit.
    – Laurel
    Nov 21, 2021 at 20:08
  • 1
    Thanks for the info. In a perfect world anyone with any question about a shell script in a shell that shellcheck supports (which is more than just bash) should be required to clean it with shellcheck first. It's a real shame to have a tool like that available and not use it but instead repeatedly waste people's time stating the same things the tool could report, explain, and usually tell them how to fix.
    – Ed Morton
    Nov 21, 2021 at 20:14
  • 3
    @EdMorton It's very similar on SO where we often get a question that's just a typo (e.g., mismatched bracket) inside a really long code snippet. Or some times they ask "why this doesn't work" but there are multiple problems all down to syntax. Flagging these early saves the question asker some time and the people who then have to read that question, too. I'd love to have support for early warnings that might differ per tag.
    – VLAZ
    Nov 22, 2021 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .