Brain-O-Meter

Mar 01, 2010 18:58


$ measure() { wget -qO- "$1" | sed 's/
/\n&/g' | \ awk -F'' '/^
/ {print $1 ( Read more... )

shell, reddit, english, fun

Leave a comment

Comments 4

ext_4199 March 1 2010, 19:19:21 UTC
Btw, you don't need all those end-of-line-escapes in your script. Actually you don't even need braces in function definition.

Reply

vorotylo March 1 2010, 20:29:10 UTC

> Actually you don't even need braces in function definition.

I do.

$ foo() echo jopa;
bash: syntax error near unexpected token `echo'
$ foo() { echo jopa; }
$ foo
jopa

> you don't need all those end-of-line-escapes in your script.

I don't, but they improve readability by telling "it's not finished yet". :)

Reply

ext_4199 March 1 2010, 20:41:22 UTC
Oops, my bad. I just quickly checked in some shells but haven't checked the standard.
OTOH, just to show that braces in principle can be omitted, this should work in any POSIX-compliant shell:

foo() for i in jopa; do echo $i; done

Reply

vorotylo March 1 2010, 20:44:02 UTC
That's interesting. Thanks!

Reply


Leave a comment

Up