9

I am currently writing a Bash script, and I found the exact answer to my programming question here: How can I list files with their absolute path in linux?

Note that the question I used is currently closed as off-topic. I have seen that the debate is that Bash questions belong on SuperUser or Unix/Linux, unless you paste the exact same commands into a .sh file and run it. (See: Tim Post's answer on Why was my Bash programming question on the `&` symbol closed? for example) This seems pretty illogical to me for the following reasons:

  1. There is no difference between bash scripting and bash typing other than the time period in which you type the commands (ahead-of-time or real-time as you need them).
  2. The question is exactly the same whether you're typing it out in real time or typing it into a Bash script. In fact, many Bash programmers will try individual commands live on the command line to make sure they work properly before pasting them into the script. Literally the exact same question could be made "on-topic" on SO by just pre-pending this sentence to the question: "I'm currently writing a Bash script and...". In other words, it isn't the question that we care about it, it is the context, when the context doesn't change either the question or the answer? What if future programmers writing a Bash script have the same question but never see it because they don't want to search 4 different sites for where some random mod thinks it is most on-topic (there can be arguments made that Bash questions belong on SO, SuperUser, Unix&Linux, and AskUbuntu. What if I'm typing my Bash commands in real-time (so not into a script) on an Ubuntu machine...)? Major dilemma...
  3. Bash is a very commonly used programming tool. For many of the programmers I work with, Bash/Vim or Bash/Emacs is their IDE. SO is a site for programmers.
  4. People tend to post questions/seek answers on whichever site they are most familiar with. So, if someone isn't a programmer, but writes Bash scripts as part of their system administrator job, their questions would naturally be more related to SuperUser or Unix/Linux. On the other hand, people writing Bash scripts for programming purposes tend to look here on SO. This is a natural sorting algorithm that helps address the problem of many legitimate overlapping jurisdictions.

Can we not be so quick to throw away excellent questions that benefit a lot of people (as evidenced by the high vote counts and comments expressing frustration and outrage at their closure), and instead focus our efforts on generating awesome content and bouncing the questions that clearly need to go (such as the "Do you haz teh codez")?

4
  • 6
    The question you linked is not about bash, it's about ls/find. Those are just programs, not scripting languages. You can run any program at all from bash - that doesn't make questions about every program on-topic.
    – Blorgbeard
    Mar 19 '14 at 18:48
  • @Blorgbeard I don't disagree with you, but those programs (and many other of the GNU tool set) are used extensively as part of scripts. I wouldn't consider launching ls/find for the purposes of programmaticly processing their output to be equivalent to launching a generic program. In this specific case not many users care about relative vs. absolute unless they're writing a script. It is like saying a knife is a cooking tool, so questions about how to sharpen it should be asked on the cooking site instead of the martial arts site, even though the user is sharpening the blade for combat Mar 19 '14 at 19:01
  • The possible duplicate, meta.stackexchange.com/q/129598/215239 is a fantastic question with a fantastic answer, though the word "Bash" appears exactly 0 times on that page. This question is about a very specific category which is extremely ambiguous, and the question you linked is extremely broad and abstract. I'm sure it doesn't matter but I totally disagree that it is a duplicate. If you really want to close my question, mark it as a dup of meta.stackexchange.com/q/166791/215239. That's at least close to what I'm asking. Mar 19 '14 at 21:27
  • @Freedom_Ben I think it's about what the question boils down to. The asker might be writing a script, but unless that fact actually impacts the question, the question is not about scripting. Note that the "dupe" you linked to refers to a question that has now been reopened, and rightly so, because it actually deals with bash syntax. I'm not sure that knife-sharpening questions would belong on either cooking or martial arts, but "I'm making a salad, how should I grow the tomatoes?" belongs on the gardening site, not the cooking site.
    – Blorgbeard
    Mar 19 '14 at 22:13
7

Bash is a tool commonly used for programming, but it's not primarily a programming tool. It's a Unix/Linux command line. If your question is about how to do something that's commonly going to be entered at the command line (like listing files, for example), it's a question best asked on Super User or UNIX & Linux (sites that didn't exist in 2008, when "How can I list files..." was asked). If you're writing a script, you can ask your question on Stack Overflow.

Can we not be so quick to throw away excellent questions that benefit a lot of people...

That question isn't thrown away. It's been closed for two years and doesn't have a single delete vote. You were still able to find it to get the information you needed.

13
  • That particular question wasn't thrown away (because as you point out I was still able to find it), but how many other questions never make it to life because they are closed before they get a good answer? Mar 19 '14 at 17:13
  • @Freedom_Ben I would hope somewhere around zero, since we now have several sites where questions like that one are perfectly on-topic. Mar 19 '14 at 17:14
  • 5
    I'm not trying to be contentious, but your criteria for where a question belongs in this answer are quite ambiguous. Listing files is a very common task in a shell script as well as general command line. I write quite a few shell scripts and I probably list files in some form or another in every one of them, with few exceptions. Perhaps we should enumerate which specific bash tasks don't belong on SO, such as, "If you're listing files, that's off-topic." If you're listing files so you can put them in an array, iterate over them to perform an action based on other criteria, well that's ok.. Mar 19 '14 at 17:24
  • @Freedom_Ben If you have other lines of code surrounding your ls command, you're writing a script and it's on-topic on Stack Overflow. Just show those lines of code. Mar 19 '14 at 17:27
  • Even if those lines of code have nothing to do with the question? Mar 19 '14 at 17:30
  • 1
    I'm not sure exactly WHOSE side this supports, but wouldn't one say "if the question is only about the ls portion all the other lines should be removed unless they are actually relevant to the question" which will inevitably lead you back to the same question? And more ironically, is the scripting question ON-TOPIC on both superuser/linux and SO?
    – UpAndAdam
    Mar 19 '14 at 17:33
  • @BilltheLizard Out of curiosity wouldn't it also not be eligible for deletion because it has answers? Or can that be gotten around?
    – UpAndAdam
    Mar 19 '14 at 17:35
  • @Freedom_Ben If the surrounding lines of code have nothing to do with the question, what are they doing in close proximity to the line of code you're writing? This question really boils down to who do you want answering your question: these people or these people? Most bash questions are on-topic on SO, but some fit better on other sites. Mar 19 '14 at 17:36
  • 2
    @UpAndAdam The author can't delete a question that has upvoted answers with one vote, but it can still be deleted by community vote or by a moderator. Mar 19 '14 at 17:37
  • @BilltheLizard The lines are in proximity because they are acting on the listing of files, but their presence doesn't affect the output of the command being questioned. For example, using find to list absolute paths instead of relative paths. The code pipes that output to sed which does some magic on it, and stores it in an array. Later on the array is iterated through and compared to another file listing to obtain a union, which is then used as a whitelist for some other commands, etc. Thank you for the discussion BTW Mar 19 '14 at 17:48
  • @BilltheLizard thanks, that's what I thought, can the author even contribute to the vote to delete it? seems like they can't (which kinda makes sense) (not withstanding author being a moderator)
    – UpAndAdam
    Mar 19 '14 at 18:05
  • @UpAndAdam I'm not sure. I don't think the author is even allowed to vote to delete, but I don't have any closed questions on sites where I'm not a moderator to test with. Mar 19 '14 at 18:08
  • @BilltheLizard Thanks, I figured as much and realized the problem you'd face with that. I can tell you for sure I don't seem to be able to vote to delete my own posts which is how i learned about the answer present restriction :-p
    – UpAndAdam
    Mar 19 '14 at 18:10
3

The particular thing that you wanted to do has no special connection to programming.

Any shell user at any moment might want some absolute pathnames for any purposes, with no script involved at all, one bit.

If you were asking for help with ls and/or find that was truly tied to scripting, I'd have a different opinion. For example, if you needed to parse the output, or deal with requoting, or anything else specific to programming.

1
  • I'll give you that the particular question about absolute v. relative pathnames is not especially connected to programming, so in this case I could see that question at home on SU or UL. However, by the standards put forth by Tim Post, my question is about programming because I'm using it in a script (meta.stackexchange.com/a/166798/215239). My specific complaint is with the ambiguity, inconsistency, and subjectivity with which moderators approach these types of Bash questions Mar 19 '14 at 22:26
3

Literally the exact same question could be made "on-topic" on SO by just pre-pending this sentence to the question: "I'm currently writing a Bash script and...".

I disagree.

There really are two parts to writing a Bash script. The first part is more like programming, where you use variables, loops, if statements, etc. The second part is more like using a program from the command line. Often the output of the latter is used as input to the former. But getting your exact command working the way you want it to doesn't automatically become programming just because it is used in a script.

To see the difference, think about how you go about debugging it. If you're opening up a second Bash prompt and trying to perfect the command in question, then it belongs on Super User or Server Fault or Ask Ubuntu or whatever is most appropriate. But if you are thinking to yourself, "Man, I wish I could set a breakpoint and step through this and inspect the variables, etc." then it is a programming question that belongs on Stack Overflow.

2
  • I agree with your first paragraph, and I think you make a great point. That is a good way to make the distinction. This is one of the reasons I asked the question though, because actual SO moderators agree with my quote that you and I consider flawed (see moderator Tim Post's response here -> meta.stackexchange.com/questions/166791/…). My bringing that point up was as an example of why I disagree. It is illogical to turn something into programming just by prepending the sentence. You and I are in agreement. Mar 19 '14 at 22:10
  • Interesting. I didn't realize that. Mar 19 '14 at 23:08
2

When I step back further I'm not sure because the thought of other parallels comes to mind. Git, SVN, Mercurial, etc. would all seem to fall under this as well in most cases. And yet they are almost always on topic. I'm playing devil's advocate here a bit, but when I think about it, many times the answer gets cloudy.

On one hand, I really think Bill has a great point in that the context kind of matters and yet on the other hand if you reduce the problem down enough, it seems like it will usually fall down to one of three things.

  1. Something that is simplified to be nothing more than a simple command line question (how do to use ls)
  2. Something that is clearly script specific, because it involves some assortment of sourcing multiple scripts, variable expansion, escaping characters variances because you are within a script, the output is going to yet another script, intricacies of calling scripts from scripts.
  3. Those which fall somewhere in the middle

It seems like everyone agrees that type 1 isn't really a fit for Stack Overflow, and it seems like everyone agrees that type 2 is. The challenge seem to lie in #3, particularly in that in my estimation most new users will often post a question that initially looks like a 2 to either them or a passerby, but when simplified is clearly a 1.

To me that is the challenge point, particularly in that I don't get the feeling there is a consensus as to whether you over-step your role as an editor or not if you scrape out the parts of the question that weren't relevant, which transform it to being type 1. I think most might even reject this type of edit. This of course means that many times people otherwise willing to make the refinement won't, leaving it solely for moderators and higher-level users, which seems to waste the ability of others and simply allow more garbage answers to appear to the garbage question...

All of that leaves me with the sense that it's one of these Stack Overflow cases, (that is classically frustrating and confusing to up and coming mid-rep users trying to contribute more), that is best left for the high-rep and moderators to sort out. To me the lack of a clear agreed upon approach, and/or consensus regarding the item in question paired with the edits needed to reform the question, which have to go through the reviews (which they then might reject or say it wasted too many reviewers time and was minor), is their roundabout way of saying we shouldn't be doing/worrying about this and discouraging 'us' from engaging in these activities. (That is, it's good and OK when you get it right and reviewers happen to like it at each step, but it's not really guaranteed that they will, and it just wastes time so you might not want to bother.)

I find it disheartening, but that's the reality I'm learning to accept here, when many things are subjective and view point differs. But maybe it's just that.

Very intersting question also in the sense of, if you are looking for the answer which site do I search first? A lot of similar things happen on the sites Ask Ubuntu, and Unix & Linux for what it's worth as well.

1
  • Good thoughts, thanks man! Mar 19 '14 at 21:28

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