how to return from bash function with a message? -


I have a function that calls a command, when the command fails, I have to resize a message and then signal failure .

EDIT: Sorry, I do not remember that if I had an attempt to do this, as other answers have said, then I may have made a mistake, so I am removing it .

This one works fine:

  function F () {command || Return 1}   

But I will have to resign the message to indicate due to failure, so I tried to do it, even this function does not come back

  function f () {command || (Echo "message" & amp; amp; amp; amp; amp;; refund1)}   

Recommend the right way to do this.

In this case:

  function F () {command | | (Resonant "message" and return 1)}   

The brackets make a subsection, and therefore returning to the function instead of returning to that subsection to avoid it, instead Use {} (but note that you need the space around them and requires a semicolon before } ). Additionally, the use of the function keyword is non-standard Finally, it is conventional to send an error message to stderr instead of stdout. Here is the definition definition as follows:

  F () {command || {Resonant "Message" & gt; & Amp; 2 & amp; Amp; Return 1; }}   

I do not know why the if ... version does not work for you (this was done to me), as long as you have brackets Do not even use it.

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -