Which one is more efficient?

Which one is more efficient?

[ "$arg" == "-f" ] || [ "$arg" == "--file" ]

or

[[ $arg =~ ^-(f|-file)$ ]]

The first one cause it's easier to read

Shell script is slow as shit already. It doesn't matter.

Use python, perl, ruby etc for speed.

Gettingagf.exe

If you need to worry about efficiency, you shouldn't be using a shell script in the first place.

>you can use python and ruby for faster script
this sentence says a lot about how slow shell is

Run them a million times each and time it. My guess though is that the first one is more efficient because it's really just a couple subtractions

...

what

Second one looks cooler though

Well I'm not going to use C for this

The first one because it doesn't require bash so you can use a lighter interpreter which will start up faster. You ships be using case in anyway.

>Use python [...] for speed.
in pretty much any other context this phrase would have been a heresy.

Using case for two conditions would be writing more than necessary

Not true. case $arg in -f|--file) thing;; esac

Esac? That looks ugly as sin.

premature optimization is for retards

You take that back motherfucker

>optimize shellscripts

>They can't read RexExp

I'll do anything to save interpretation time.

Then use C.

What about
[[ $argument =~ ^--?f(île)?$ ]]
This actually allows --f but should we care

--f should not be allowed