0

I have this:

#!/usr/bin/bash

        while read f; do
            {

#Try
        echo "$f"

}

|| { 

# Catch

printf "error"

}

    done < "${1:-/dev/stdin}";

And I would like this in one sweep

while read f; do
    {
        #Try
        echo "$f"
    } ||
    {
        # Catch

        printf "error"
    }
done < "${1:-/dev/stdin}";

For now I have to remove any blanks between the last properly indented line and the next one and do RET between the two, do the same with the next line, for all lines.

  • Why use RET rather than TAB? (IOW, why/where did you learn to "abuse" RET this way but did not learn the use of TAB at the same time?) – Stefan Jul 12 at 21:47
  • 1
    Mark the region and press TAB to reindent it. – NickD Jul 12 at 22:46
  • U are right Stefan, I must have been under some kind of spell for such inflicted hardship. – Erwann Jul 12 at 23:53
  • I'm still curious about the answer to my question (to see if there's something we could fix in some doc to avoid such hardship). – Stefan Jul 13 at 14:48
  • No, there is nothing in the doc that lead me to that, just a habit I picked up for whatever reason. – Erwann Jul 13 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.