Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-8946

bin/post script stdin detection is faulty

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.0
    • Fix Version/s: 5.5.2, 5.6, 6.0.1, 6.1
    • Component/s: SimplePostTool
    • Labels:
      None
    • Environment:

      Ubuntu

      Description

      Summary: I think the post bash script tries to detect stdin the wrong way.

      If I run "post -h" I see some examples, to include this:

      echo '{commit: {}}' | bin/post -c my_collection -type application/json -out yes -d
      

      However if I try it, Solr returns this error: Cannot parse provided JSON: JSON Parse Error: char=<,position=0 BEFORE='<' AFTER='add/>'

      I see that post is sending an <add /> in certain cases, but it's not supposed to when the mode is stdin. Looking closer, it appears to be because of this line:
      if [[ -s /dev/stdin ]]; then
      If I change it to this (which I figured out after googling around; I'm no bash expert!):
      if [[ ! -t 0 ]]; then
      Apparently '0' represents stdin. It works for me. Timothy Potter might you take a look? I'd be happy to add a formal patch & commit for this trivial change but it really needs other eyes.

        Attachments

          Activity

            People

            • Assignee:
              dsmiley David Smiley
              Reporter:
              dsmiley David Smiley
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: